You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/09/14 10:31:29 UTC
[camel-quarkus] branch main updated: Salesforce : add Platform
events test fixes #2938
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 6b77c9e Salesforce : add Platform events test fixes #2938
6b77c9e is described below
commit 6b77c9ecf6d836fd28912670835ebb0d3d38aa9d
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Sun Sep 5 18:49:21 2021 +0200
Salesforce : add Platform events test fixes #2938
---
integration-tests/salesforce/README.adoc | 2 ++
integration-tests/salesforce/pom.xml | 38 +++++++++++++++++++++-
.../component/salesforce/SalesforceResource.java | 7 ++++
.../component/salesforce/SalesforceRoutes.java | 6 ++++
.../salesforce/SalesforceIntegrationTest.java | 12 +++++++
5 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/integration-tests/salesforce/README.adoc b/integration-tests/salesforce/README.adoc
index e85a862..1b3acd1 100644
--- a/integration-tests/salesforce/README.adoc
+++ b/integration-tests/salesforce/README.adoc
@@ -11,6 +11,8 @@ Next create a new 'Connected App' from the app manager page. You may need to adj
Next create a document named 'test'.
+Next create a new Platform Event named `TestEvent`. Set Publish Behavior to `Publish Immediately`. Save and make sure the API name is `TestEvent__e`.
+
You can find the app OAuth settings by choosing the 'view' option from the app manager page. Then set the following environment variables.
[source,shell]
diff --git a/integration-tests/salesforce/pom.xml b/integration-tests/salesforce/pom.xml
index df077a9..bad69a9 100644
--- a/integration-tests/salesforce/pom.xml
+++ b/integration-tests/salesforce/pom.xml
@@ -36,7 +36,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-seda-deployment</artifactId>
+ <artifactId>camel-quarkus-seda</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
@@ -54,6 +58,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- dependencies needed to mock Salesforce API -->
<dependency>
@@ -77,6 +86,33 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-seda-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
diff --git a/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceResource.java b/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceResource.java
index 6f4d184..01632a9 100644
--- a/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceResource.java
+++ b/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceResource.java
@@ -289,4 +289,11 @@ public class SalesforceResource {
return queryRecordsPushTopic.getRecords().get(0).getId();
}
+
+ @Path("platform/event")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String getPlatformEvent() {
+ return consumerTemplate.receiveBody("salesforce:event/TestEvent__e?rawPayload=true", 10000, String.class);
+ }
}
diff --git a/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceRoutes.java b/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceRoutes.java
index 66658b8..383bbd7 100644
--- a/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceRoutes.java
+++ b/integration-tests/salesforce/src/main/java/org/apache/camel/quarkus/component/salesforce/SalesforceRoutes.java
@@ -87,6 +87,12 @@ public class SalesforceRoutes extends RouteBuilder {
+ "updateTopic=true&sObjectQuery=SELECT Id, Name FROM Account")
.to("seda:RawPayloadCamelTestTopic");
+ // it takes some time for the subscriber to subscribe, so we'll try to
+ // send repeated platform events and wait until the first one is
+ // received
+ from("timer:platform")
+ .setBody().simple("{}")
+ .to("salesforce:createSObject?sObjectName=TestEvent__e");
}
}
}
diff --git a/integration-tests/salesforce/src/test/java/org/apache/camel/quarkus/component/salesforce/SalesforceIntegrationTest.java b/integration-tests/salesforce/src/test/java/org/apache/camel/quarkus/component/salesforce/SalesforceIntegrationTest.java
index 5dffd4e..ecf5fa8 100644
--- a/integration-tests/salesforce/src/test/java/org/apache/camel/quarkus/component/salesforce/SalesforceIntegrationTest.java
+++ b/integration-tests/salesforce/src/test/java/org/apache/camel/quarkus/component/salesforce/SalesforceIntegrationTest.java
@@ -20,12 +20,15 @@ import java.util.UUID;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@EnabledIfEnvironmentVariable(named = "SALESFORCE_USERNAME", matches = ".+")
@EnabledIfEnvironmentVariable(named = "SALESFORCE_PASSWORD", matches = ".+")
@@ -107,4 +110,13 @@ public class SalesforceIntegrationTest {
}
}
+ @Test
+ void testPlatformEvents() {
+ String event = given()
+ .contentType(ContentType.JSON)
+ .get("/salesforce/platform/event")
+ .asString();
+ assertTrue(event.contains("channel=/event/TestEvent__e"));
+ }
+
}