Repository: camel
Updated Branches:
  refs/heads/master 8718152da -> 65b7ac727


http://git-wip-us.apache.org/repos/asf/camel/blob/65b7ac72/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/MapOfMapsConverterTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/MapOfMapsConverterTest.java
 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/MapOfMapsConverterTest.java
new file mode 100644
index 0000000..e47209f
--- /dev/null
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/MapOfMapsConverterTest.java
@@ -0,0 +1,154 @@
+/**
+ * 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.salesforce.api.dto.composite;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.Map;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.xml.XppDomReader;
+import com.thoughtworks.xstream.io.xml.xppdom.XppDom;
+
+import org.junit.Test;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class MapOfMapsConverterTest {
+
+    Converter converter = new MapOfMapsConverter();
+
+    XmlPullParser parser;
+
+    public MapOfMapsConverterTest() throws XmlPullParserException {
+        final XmlPullParserFactory factory = 
XmlPullParserFactory.newInstance();
+        parser = factory.newPullParser();
+
+    }
+
+    @Test
+    public void shoulUnmarshallToMapTrivialCase() throws Exception {
+        final Object object = 
converter.unmarshal(readerFor("<holder><some>value</some></holder>"), null);
+
+        assertNotNull(object);
+        assertTrue(object instanceof Map);
+
+        @SuppressWarnings("unchecked")
+        final Map<String, String> map = (Map<String, String>) object;
+
+        assertEquals(1, map.size());
+        assertEquals("value", map.get("some"));
+    }
+
+    @Test
+    public void shoulUnmarshallWithAttributesToMapTrivialCase() throws 
Exception {
+        final Object object = converter.unmarshal(readerFor("<holder><some 
attr=\"attrVal\">value</some></holder>"),
+            null);
+
+        assertNotNull(object);
+        assertTrue(object instanceof Map);
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> map = (Map<String, Object>) object;
+
+        assertEquals(1, map.size());
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> some = (Map<String, Object>) map.get("some");
+
+        assertEquals(2, some.size());
+
+        assertEquals("value", some.get("some"));
+
+        @SuppressWarnings("unchecked")
+        final Map<String, String> attributes = (Map<String, String>) 
some.get("attributes");
+        assertEquals(1, attributes.size());
+        assertEquals("attrVal", attributes.get("attr"));
+    }
+
+    @Test
+    public void shoulUnmarshallToMapWithTwoElements() throws Exception {
+        final Object object = converter
+            
.unmarshal(readerFor("<holder><some1>value1</some1><some2>value2</some2></holder>"),
 null);
+
+        assertNotNull(object);
+        assertTrue(object instanceof Map);
+
+        @SuppressWarnings("unchecked")
+        final Map<String, String> map = (Map<String, String>) object;
+
+        assertEquals(2, map.size());
+        assertEquals("value1", map.get("some1"));
+        assertEquals("value2", map.get("some2"));
+    }
+
+    @Test
+    public void shoulUnmarshallToMapWithNestedMap() throws Exception {
+        final Object object = 
converter.unmarshal(readerFor("<holder><some1><some2>value2</some2></some1></holder>"),
+            null);
+
+        assertNotNull(object);
+        assertTrue(object instanceof Map);
+
+        @SuppressWarnings("unchecked")
+        final Map<String, String> map = (Map<String, String>) object;
+
+        assertEquals(1, map.size());
+        assertEquals(Collections.singletonMap("some2", "value2"), 
map.get("some1"));
+    }
+
+    @Test
+    public void shoulUnmarshallToMapWithNestedMapAndAttributes() throws 
Exception {
+        final Object object = converter.unmarshal(
+            readerFor("<holder><some1 attr1=\"val1\"><some2 
attr2=\"val2\">value2</some2></some1></holder>"), null);
+
+        assertNotNull(object);
+        assertTrue(object instanceof Map);
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> map = (Map<String, Object>) object;
+
+        assertEquals(1, map.size());
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> some1 = (Map<String, Object>) 
map.get("some1");
+
+        assertEquals(2, some1.size());
+
+        assertEquals(Collections.singletonMap("attr1", "val1"), 
some1.get("attributes"));
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> some2 = (Map<String, Object>) 
some1.get("some2");
+        assertEquals(2, some2.size());
+
+        assertEquals(Collections.singletonMap("attr2", "val2"), 
some2.get("attributes"));
+    }
+
+    HierarchicalStreamReader readerFor(final String xml) throws 
XmlPullParserException, IOException {
+        parser.setInput(new StringReader(xml));
+        final XppDom dom = XppDom.build(parser);
+
+        final HierarchicalStreamReader reader = new XppDomReader(dom);
+        return reader;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/65b7ac72/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchResponseTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchResponseTest.java
 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchResponseTest.java
new file mode 100644
index 0000000..d8dfb89
--- /dev/null
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchResponseTest.java
@@ -0,0 +1,156 @@
+/**
+ * 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.salesforce.api.dto.composite;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.thoughtworks.xstream.XStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class SObjectBatchResponseTest {
+
+    static void assertResponse(final SObjectBatchResponse response) {
+        assertNotNull("Response should be parsed", response);
+
+        assertFalse("It should not have errors", response.hasErrors());
+
+        final List<SObjectBatchResult> results = response.getResults();
+        assertEquals("It should contain 2 results", 2, results.size());
+
+        final SObjectBatchResult firstResult = results.get(0);
+        assertEquals("First result should have status code of 204", 204, 
firstResult.getStatusCode());
+        assertNull("First result contain no data", firstResult.getResult());
+
+        final SObjectBatchResult secondResult = results.get(1);
+        assertEquals("Second result should have status code of 200", 200, 
secondResult.getStatusCode());
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> secondResultMap = (Map<String, Object>) 
secondResult.getResult();
+        @SuppressWarnings("unchecked")
+        final Map<String, String> attributes = (Map<String, String>) 
secondResultMap.get("attributes");
+        assertEquals("Second result data should have attribute type set to 
`Account`", "Account",
+            attributes.get("type"));
+        assertEquals("Second result data should have attribute url set as 
expected",
+            "/services/data/v34.0/sobjects/Account/001D000000K0fXOIAZ", 
attributes.get("url"));
+
+        assertEquals("Second result data should have `NewName` set as 
expected", "NewName",
+            secondResultMap.get("Name"));
+        assertEquals("Second result data should have `BillingPostalCode` set 
as expected", "94105",
+            secondResultMap.get("BillingPostalCode"));
+        assertEquals("Second result data should have `Id` set as expected", 
"001D000000K0fXOIAZ",
+            secondResultMap.get("Id"));
+    }
+
+    @Test
+    public void shouldDeserializeFromJson() throws IOException {
+
+        final String json = "{\n"//
+            + "   \"hasErrors\" : false,\n"//
+            + "   \"results\" : [{\n"//
+            + "      \"statusCode\" : 204,\n"//
+            + "      \"result\" : null\n"//
+            + "      },{\n"//
+            + "      \"statusCode\" : 200,\n"//
+            + "      \"result\": {\n"//
+            + "         \"attributes\" : {\n"//
+            + "            \"type\" : \"Account\",\n"//
+            + "            \"url\" : 
\"/services/data/v34.0/sobjects/Account/001D000000K0fXOIAZ\"\n"//
+            + "         },\n"//
+            + "         \"Name\" : \"NewName\",\n"//
+            + "         \"BillingPostalCode\" : \"94105\",\n"//
+            + "         \"Id\" : \"001D000000K0fXOIAZ\"\n"//
+            + "      }\n"//
+            + "   }]\n"//
+            + "}";
+
+        final ObjectMapper mapper = new ObjectMapper();
+
+        final SObjectBatchResponse response = 
mapper.readerFor(SObjectBatchResponse.class).readValue(json);
+
+        assertResponse(response);
+    }
+
+    @Test
+    public void shouldDeserializeFromXml() {
+        final String xml = "<batchResults>\n"//
+            + "    <hasErrors>false</hasErrors>\n"//
+            + "    <results>\n"//
+            + "        <batchResult>\n"//
+            + "            <statusCode>204</statusCode>\n"//
+            + "            <result/>\n"//
+            + "        </batchResult>\n"//
+            + "        <batchResult>\n"//
+            + "            <statusCode>200</statusCode>\n"//
+            + "            <result>\n"//
+            + "                <Account type=\"Account\" 
url=\"/services/data/v34.0/sobjects/Account/001D000000K0fXOIAZ\">\n"//
+            + "                    <Id>001D000000K0fXOIAZ</Id>\n"//
+            + "                    <Name>NewName</Name>\n"//
+            + "                    
<BillingPostalCode>94105</BillingPostalCode>"//
+            + "                </Account>\n"//
+            + "            </result>\n"//
+            + "        </batchResult>\n"//
+            + "    </results>\n"//
+            + "</batchResults>";
+
+        final XStream xStream = new XStream();
+        xStream.processAnnotations(new Class[] {SObjectBatchResponse.class});
+
+        final SObjectBatchResponse response = (SObjectBatchResponse) 
xStream.fromXML(xml);
+
+        assertNotNull("Response should be parsed", response);
+
+        assertFalse("It should not have errors", response.hasErrors());
+
+        final List<SObjectBatchResult> results = response.getResults();
+        assertEquals("It should contain 2 results", 2, results.size());
+
+        final SObjectBatchResult firstResult = results.get(0);
+        assertEquals("First result should have status code of 204", 204, 
firstResult.getStatusCode());
+        assertTrue("First result contain no data", ((Map) 
firstResult.getResult()).isEmpty());
+
+        final SObjectBatchResult secondResult = results.get(1);
+        assertEquals("Second result should have status code of 200", 200, 
secondResult.getStatusCode());
+
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> secondResultMap = (Map<String, Object>) 
secondResult.getResult();
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> account = (Map<String, Object>) 
secondResultMap.get("Account");
+
+        @SuppressWarnings("unchecked")
+        final Map<String, String> attributes = (Map<String, String>) 
account.get("attributes");
+        assertEquals("Second result data should have attribute type set to 
`Account`", "Account",
+            attributes.get("type"));
+        assertEquals("Second result data should have attribute url set as 
expected",
+            "/services/data/v34.0/sobjects/Account/001D000000K0fXOIAZ", 
attributes.get("url"));
+
+        assertEquals("Second result data should have `NewName` set as 
expected", "NewName", account.get("Name"));
+        assertEquals("Second result data should have `BillingPostalCode` set 
as expected", "94105",
+            account.get("BillingPostalCode"));
+        assertEquals("Second result data should have `Id` set as expected", 
"001D000000K0fXOIAZ", account.get("Id"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/65b7ac72/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchTest.java
 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchTest.java
new file mode 100644
index 0000000..00c3d0b
--- /dev/null
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/dto/composite/SObjectBatchTest.java
@@ -0,0 +1,229 @@
+/**
+ * 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.salesforce.api.dto.composite;
+
+import java.util.regex.Pattern;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.converters.reflection.FieldDictionary;
+import 
com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
+
+import org.apache.camel.component.salesforce.api.dto.AnnotationFieldKeySorter;
+import 
org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch.Method;
+import org.apache.camel.component.salesforce.dto.generated.Account;
+import 
org.apache.camel.component.salesforce.dto.generated.Account_IndustryEnum;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class SObjectBatchTest {
+
+    private final SObjectBatch batch;
+
+    public SObjectBatchTest() {
+        batch = new SObjectBatch("37.0");
+
+        final Account account = new Account();
+        account.setName("NewAccountName");
+        account.setIndustry(Account_IndustryEnum.ENVIRONMENTAL);
+        batch.addCreate(account);
+
+        batch.addDelete("Account", "001D000000K0fXOIAZ");
+
+        batch.addGet("Account", "001D000000K0fXOIAZ", "Name", 
"BillingPostalCode");
+
+        batch.addGetByExternalId("Account", "EPK", "12345");
+
+        batch.addGetRelated("Account", "001D000000K0fXOIAZ", "CreatedBy", 
"Name");
+
+        batch.addLimits();
+
+        Account updates1 = new Account();
+        updates1.setName("NewName");
+        updates1.setAccountNumber("AC12345");
+        batch.addUpdate("Account", "001D000000K0fXOIAZ", updates1);
+
+        Account updates2 = new Account();
+        updates2.setName("NewName");
+        batch.addUpdateByExternalId("Account", "EPK", "12345", updates2);
+
+        Account updates3 = new Account();
+        updates3.setName("NewName");
+        batch.addUpsertByExternalId("Account", "EPK", "12345", updates3);
+
+        batch.addGeneric(Method.PATCH, "/some/url");
+
+        batch.addQuery("SELECT Name FROM Account");
+
+        batch.addQueryAll("SELECT Name FROM Account");
+
+        batch.addSearch("FIND {joe}");
+    }
+
+    @Test
+    public void shouldSerializeToJson() throws JsonProcessingException {
+        final String json = 
Pattern.compile("\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)", Pattern.DOTALL)
+            .matcher("{"//
+                + "\"batchRequests\" : ["//
+                + "    {"//
+                + "        \"method\" : \"POST\","//
+                + "        \"url\" : \"v37.0/sobjects/Account/\","//
+                + "        \"richInput\" : {\"Industry\" : \"Environmental\" , 
\"Name\" : \"NewAccountName\"}"//
+                + "    },{"//
+                + "        \"method\" : \"DELETE\","//
+                + "        \"url\" : 
\"v37.0/sobjects/Account/001D000000K0fXOIAZ\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : 
\"v37.0/sobjects/Account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : \"v37.0/sobjects/Account/EPK/12345\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : 
\"v37.0/sobjects/Account/001D000000K0fXOIAZ/CreatedBy?fields=Name\"},{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : \"v37.0/limits/\""//
+                + "    },{"//
+                + "        \"method\" : \"PATCH\","//
+                + "        \"url\" : 
\"v37.0/sobjects/Account/001D000000K0fXOIAZ\","//
+                + "        \"richInput\" : {\"AccountNumber\" : \"AC12345\", 
\"Name\" : \"NewName\"}"//
+                + "    },{"//
+                + "        \"method\" : \"PATCH\","//
+                + "        \"url\" : \"v37.0/sobjects/Account/EPK/12345\","//
+                + "        \"richInput\" : {\"Name\" : \"NewName\"}"//
+                + "    },{"//
+                + "        \"method\" : \"PATCH\","//
+                + "        \"url\" : \"v37.0/sobjects/Account/EPK/12345\","//
+                + "        \"richInput\" : {\"Name\" : \"NewName\"}"//
+                + "    },{"//
+                + "        \"method\" : \"PATCH\","//
+                + "        \"url\" : \"v37.0/some/url\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : \"v37.0/query/?q=SELECT Name FROM 
Account\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : \"v37.0/queryAll/?q=SELECT Name FROM 
Account\""//
+                + "    },{"//
+                + "        \"method\" : \"GET\","//
+                + "        \"url\" : \"v37.0/search/?q=FIND {joe}\""//
+                + "    }]"//
+                + "}")
+            .replaceAll("");
+
+        final ObjectMapper mapper = new ObjectMapper();
+
+        final String serialized = 
mapper.writerFor(SObjectBatch.class).writeValueAsString(batch);
+
+        assertEquals("Should serialize as expected by Salesforce", json, 
serialized);
+    }
+
+    @Test
+    public void shouldSerializeToXml() {
+        final String xml = "<batch>\n"//
+            + "  <batchRequests>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>POST</method>\n"//
+            + "      <url>v37.0/sobjects/Account/</url>\n"//
+            + "      <richInput>\n"//
+            + "        <Account>\n"//
+            + "          <Name>NewAccountName</Name>\n"//
+            + "          <Industry>Environmental</Industry>\n"//
+            + "        </Account>\n"//
+            + "      </richInput>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>DELETE</method>\n"//
+            + "      <url>v37.0/sobjects/Account/001D000000K0fXOIAZ</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      
<url>v37.0/sobjects/Account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      <url>v37.0/sobjects/Account/EPK/12345</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      
<url>v37.0/sobjects/Account/001D000000K0fXOIAZ/CreatedBy?fields=Name</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      <url>v37.0/limits/</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>PATCH</method>\n"//
+            + "      <url>v37.0/sobjects/Account/001D000000K0fXOIAZ</url>\n"//
+            + "      <richInput>\n"//
+            + "        <Account>\n"//
+            + "          <Name>NewName</Name>\n"//
+            + "          <AccountNumber>AC12345</AccountNumber>\n"//
+            + "        </Account>\n"//
+            + "      </richInput>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>PATCH</method>\n"//
+            + "      <url>v37.0/sobjects/Account/EPK/12345</url>\n"//
+            + "      <richInput>\n"//
+            + "        <Account>\n"//
+            + "          <Name>NewName</Name>\n"//
+            + "        </Account>\n"//
+            + "      </richInput>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>PATCH</method>\n"//
+            + "      <url>v37.0/sobjects/Account/EPK/12345</url>\n"//
+            + "      <richInput>\n"//
+            + "        <Account>\n"//
+            + "          <Name>NewName</Name>\n"//
+            + "        </Account>\n"//
+            + "      </richInput>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>PATCH</method>\n"//
+            + "      <url>v37.0/some/url</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      <url>v37.0/query/?q=SELECT Name FROM Account</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      <url>v37.0/queryAll/?q=SELECT Name FROM Account</url>\n"//
+            + "    </batchRequest>\n"//
+            + "    <batchRequest>\n"//
+            + "      <method>GET</method>\n"//
+            + "      <url>v37.0/search/?q=FIND {joe}</url>\n"//
+            + "    </batchRequest>\n"//
+            + "  </batchRequests>\n"//
+            + "</batch>";
+
+        final PureJavaReflectionProvider reflectionProvider = new 
PureJavaReflectionProvider(
+            new FieldDictionary(new AnnotationFieldKeySorter()));
+        final XStream xStream = new XStream(reflectionProvider);
+        xStream.aliasSystemAttribute(null, "class");
+        xStream.processAnnotations(SObjectBatch.class);
+        xStream.processAnnotations(batch.objectTypes());
+
+        final String serialized = xStream.toXML(batch);
+
+        assertEquals("Should serialize as expected by Salesforce", xml, 
serialized);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/65b7ac72/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/utils/VersionTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/utils/VersionTest.java
 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/utils/VersionTest.java
new file mode 100644
index 0000000..3e61216
--- /dev/null
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/api/utils/VersionTest.java
@@ -0,0 +1,76 @@
+/**
+ * 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.salesforce.api.utils;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class VersionTest {
+
+    private static final Version V34_0 = Version.create("34.0");
+
+    private static final Version V34_3 = Version.create("34.3");
+
+    private static final Version V35_0 = Version.create("35.0");
+
+    @Test
+    public void shouldCreate() {
+        final Version version = V34_3;
+
+        assertEquals(34, version.getMajor());
+        assertEquals(3, version.getMinor());
+    }
+
+    @Test
+    public void shouldObserveApiLimits() {
+        V34_0.requireAtLeast(34, 0);
+        V34_0.requireAtLeast(33, 9);
+        V35_0.requireAtLeast(34, 0);
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldObserveApiLimitsOnMajorVersions() {
+        V35_0.requireAtLeast(36, 0);
+
+        fail("No UnsupportedOperationException thrown, but expected");
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldObserveApiLimitsOnMinorVersions() {
+        V35_0.requireAtLeast(35, 1);
+
+        fail("No UnsupportedOperationException thrown, but expected");
+    }
+
+    @Test
+    public void testComparator() {
+        assertTrue(V34_0.compareTo(V34_3) < 0);
+        assertTrue(V34_0.compareTo(V35_0) < 0);
+        assertTrue(V34_3.compareTo(V35_0) < 0);
+
+        assertTrue(V34_3.compareTo(V34_0) > 0);
+        assertTrue(V35_0.compareTo(V34_0) > 0);
+        assertTrue(V35_0.compareTo(V34_3) > 0);
+
+        assertTrue(V34_0.compareTo(V34_0) == 0);
+        assertTrue(V34_3.compareTo(V34_3) == 0);
+        assertTrue(V35_0.compareTo(V35_0) == 0);
+    }
+}

Reply via email to