This is an automated email from the ASF dual-hosted git repository.

jeremyross pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c9e09c  camel-salesforce: Should return null
9c9e09c is described below

commit 9c9e09c53d492df2d9af7080f05b3f25aadd8a60
Author: Jeremy Ross <[email protected]>
AuthorDate: Sun Jan 2 13:36:30 2022 -0600

    camel-salesforce: Should return null
    
    In case of NotFoundBehaviour.NULL
---
 .../internal/processor/JsonRestProcessor.java       |  2 ++
 .../salesforce/NotFoundIntegrationTest.java         | 21 +++++++++------------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java
 
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java
index 08c7572..cb0a1b7 100644
--- 
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java
@@ -188,6 +188,8 @@ public class JsonRestProcessor extends 
AbstractRestProcessor {
                 // if an exception is reported we should not loose it
                 if (shouldReport(ex)) {
                     exchange.setException(ex);
+                } else {
+                    out.setBody(null);
                 }
             } else if (responseEntity != null) {
                 // do we need to un-marshal a response
diff --git 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/NotFoundIntegrationTest.java
 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/NotFoundIntegrationTest.java
index 92daefe..b005026 100644
--- 
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/NotFoundIntegrationTest.java
+++ 
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/NotFoundIntegrationTest.java
@@ -19,8 +19,7 @@ package org.apache.camel.component.salesforce;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.component.salesforce.api.NoSuchSObjectException;
 import org.apache.camel.component.salesforce.dto.generated.Account;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
+import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -28,22 +27,20 @@ import static org.junit.jupiter.api.Assertions.fail;
 
 public class NotFoundIntegrationTest extends AbstractSalesforceTestBase {
 
-    @ParameterizedTest
-    @ValueSource(strings = { "XML", "JSON" })
-    public void 
shouldNotReportNotFoundExceptionFromRestApiIfConfiguredNotTo(String format) {
-        final Account got = 
template.requestBody("salesforce:getSObjectWithId?sObjectName=Account&sObjectIdName=Name&format="
-                                                 + format + 
"&notFoundBehaviour=NULL",
-                "NonExistant",
+    @Test
+    public void shouldNotReportNotFoundExceptionFromRestApiIfConfiguredNotTo() 
{
+        final Account got = 
template.requestBody("salesforce:getSObjectWithId?sObjectName=Account&sObjectIdName=Name"
+                                                 + "&notFoundBehaviour=NULL",
+                "NonExistent",
                 Account.class);
 
         assertNull(got, "Expecting null when `notFoundBehaviour` is set to 
NULL");
     }
 
-    @ParameterizedTest
-    @ValueSource(strings = { "XML", "JSON" })
-    public void shouldReportNotFoundExceptionFromRestApi(String format) {
+    @Test
+    public void shouldReportNotFoundExceptionFromRestApi() {
         try {
-            
template.requestBody("salesforce:getSObjectWithId?sObjectName=Account&sObjectIdName=Name&format="
 + format,
+            
template.requestBody("salesforce:getSObjectWithId?sObjectName=Account&sObjectIdName=Name",
                     "NonExistant", Account.class);
             fail("Expecting CamelExecutionException");
         } catch (final CamelExecutionException e) {

Reply via email to