camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject camel git commit: CAMEL-9737 : add an option to configure default resource to access
Date Thu, 24 Mar 2016 09:57:13 GMT
Repository: camel
Updated Branches:
  refs/heads/master 8a03f0e40 -> 057e87eb7


CAMEL-9737 : add an option to configure default resource to access


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

Branch: refs/heads/master
Commit: 057e87eb7af4379434384bb6f6a1cb035f2d978d
Parents: 8a03f0e
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Thu Mar 24 10:32:15 2016 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Thu Mar 24 10:42:18 2016 +0100

----------------------------------------------------------------------
 .../servicenow/ServiceNowConfiguration.java     | 13 ++++++++
 .../servicenow/ServiceNowConstants.java         |  2 +-
 .../servicenow/ServiceNowProducer.java          |  2 +-
 .../servicenow/ServiceNowTableTest.java         | 34 ++++++++++++++++++++
 4 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/057e87eb/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
index 9c0b424..ddf83d8 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
@@ -51,6 +51,8 @@ public class ServiceNowConfiguration {
     @UriParam(label = "advanced")
     private String apiUrl;
     @UriParam
+    private String resource;
+    @UriParam
     private String table;
     @UriParam
     private Boolean excludeReferenceLink = false;
@@ -152,6 +154,17 @@ public class ServiceNowConfiguration {
             && ObjectHelper.isNotEmpty(oauthClientSecret);
     }
 
+    public String getResource() {
+        return resource;
+    }
+
+    /**
+     * The default resource, can be overridden by header CamelServiceNowResource
+     */
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
     public String getTable() {
         return table;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/057e87eb/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConstants.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConstants.java
index 3dfb20e..8cd6c4b 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConstants.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConstants.java
@@ -24,7 +24,7 @@ public interface ServiceNowConstants {
 
     String RESOURCE_TABLE = "table";
     String RESOURCE_AGGREGATE = "aggregate";
-    String RESOURCE_IMPORT = "aggregate";
+    String RESOURCE_IMPORT = "import";
 
     String ACTION_RETRIEVE = "retrieve";
     String ACTION_CREATE = "create";

http://git-wip-us.apache.org/repos/asf/camel/blob/057e87eb/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowProducer.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowProducer.java
index cd7d4a7..0830bad 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowProducer.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowProducer.java
@@ -49,7 +49,7 @@ public class ServiceNowProducer extends DefaultProducer {
 
     @Override
     public void process(Exchange exchange) throws Exception {
-        final String resource = exchange.getIn().getHeader(ServiceNowConstants.RESOURCE,
String.class);
+        String resource = exchange.getIn().getHeader(ServiceNowConstants.RESOURCE, configuration.getResource(),
String.class);
 
         if (ObjectHelper.equal(ServiceNowConstants.RESOURCE_TABLE, resource, true)) {
             tableCache.get().process(exchange);

http://git-wip-us.apache.org/repos/asf/camel/blob/057e87eb/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java
b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java
index f8651a1..5075511 100644
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java
+++ b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java
@@ -53,6 +53,29 @@ public class ServiceNowTableTest extends ServiceNowTestSupport {
     }
 
     @Test
+    public void testRetrieveSomeWithDefaults() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:servicenow-defaults");
+        mock.expectedMessageCount(1);
+
+        template().sendBodyAndHeaders(
+            "direct:servicenow-defaults",
+            null,
+            new KVBuilder()
+                .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
+                .put(ServiceNowConstants.SYSPARM_LIMIT, "10")
+                .build()
+        );
+
+        mock.assertIsSatisfied();
+
+        Exchange exchange = mock.getExchanges().get(0);
+        List<Incident> items = exchange.getIn().getBody(List.class);
+
+        assertNotNull(items);
+        assertTrue(items.size() <= 10);
+    }
+
+    @Test
     public void testIncidentWorkflow() throws Exception {
 
         Incident incident = null;
@@ -280,6 +303,17 @@ public class ServiceNowTableTest extends ServiceNowTestSupport {
                         + "&model.incident=org.apache.camel.component.servicenow.model.Incident")
                     .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
                     .to("mock:servicenow");
+                from("direct:servicenow-defaults")
+                    .to("servicenow:{{env:SERVICENOW_INSTANCE}}"
+                        + "?userName={{env:SERVICENOW_USERNAME}}"
+                        + "&password={{env:SERVICENOW_PASSWORD}}"
+                        //+ "&oauthClientId={{env:SERVICENOW_OAUTH2_CLIENT_ID}}"
+                        //+ "&oauthClientSecret={{env:SERVICENOW_OAUTH2_CLIENT_SECRET}}"
+                        + "&model.incident=org.apache.camel.component.servicenow.model.Incident"
+                        + "&resource=table"
+                        + "&table=incident")
+                    .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
+                    .to("mock:servicenow-defaults");
             }
         };
     }


Mime
View raw message