Updated Branches:
  refs/heads/master 8e0cf8cca -> a59e61c7b

CAMEL-6493 - add option to select specific user relationships


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3a1db5c4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3a1db5c4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3a1db5c4

Branch: refs/heads/master
Commit: 3a1db5c45341ff588e4159baf3c6e4decf5dd6dd
Parents: f19f444
Author: Jonathan Anstey <jans...@gmail.com>
Authored: Wed Jul 10 15:05:58 2013 -0230
Committer: Jonathan Anstey <jans...@gmail.com>
Committed: Wed Jul 10 15:06:05 2013 -0230

----------------------------------------------------------------------
 .../component/yammer/YammerConfiguration.java   | 11 ++++++
 .../YammerRelationshipPollingConsumer.java      | 10 ++++++
 .../YammerRelationshipConsumerOptionTest.java   | 38 ++++++++++++++++++++
 3 files changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3a1db5c4/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
 
b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
index 92adb21..18019ca 100644
--- 
a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
+++ 
b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
@@ -49,6 +49,9 @@ public class YammerConfiguration {
     @UriParam
     private String threaded;
     
+    @UriParam
+    private String userId;
+    
     private ApiRequestor requestor;
     
     public String getConsumerKey() {
@@ -143,4 +146,12 @@ public class YammerConfiguration {
         this.threaded = threaded;
     }
 
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/3a1db5c4/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerRelationshipPollingConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerRelationshipPollingConsumer.java
 
b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerRelationshipPollingConsumer.java
index 6ef5ce5..2491b2d 100644
--- 
a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerRelationshipPollingConsumer.java
+++ 
b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerRelationshipPollingConsumer.java
@@ -22,6 +22,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.yammer.model.Relationships;
 import org.apache.camel.impl.ScheduledPollConsumer;
+import org.apache.camel.util.ObjectHelper;
 import org.codehaus.jackson.map.ObjectMapper;
 
 /**
@@ -55,6 +56,15 @@ public class YammerRelationshipPollingConsumer extends 
ScheduledPollConsumer {
             throw new Exception(String.format("%s is not a valid Yammer 
relationship function type.", function));
         }        
         
+        StringBuilder args = new StringBuilder();
+        
+        String userId = endpoint.getConfig().getUserId();
+        if (ObjectHelper.isNotEmpty(userId)) {
+            args.append("?user_id=");
+            args.append(userId);
+            url.append(args);
+        }        
+        
         return url.toString();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3a1db5c4/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerRelationshipConsumerOptionTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerRelationshipConsumerOptionTest.java
 
b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerRelationshipConsumerOptionTest.java
new file mode 100644
index 0000000..26f0742
--- /dev/null
+++ 
b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerRelationshipConsumerOptionTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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.camel.component.yammer;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class YammerRelationshipConsumerOptionTest extends 
YammerComponentTestSupport {
+
+    @Test
+    public void testOptions() throws Exception {
+        // now check if options got applied
+        assertEquals("jcamel", yammerComponent.getConfig().getUserId());
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                
from("yammer:relationships?consumerKey=aConsumerKey&consumerSecret=aConsumerSecretKey&accessToken=aAccessToken&userId=jcamel").to("mock:result");
+            }
+        };
+    }
+}

Reply via email to