Skip to content

Commit

Permalink
Salesforce : add Platform events test fixes #2938
Browse files Browse the repository at this point in the history
  • Loading branch information
zbendhiba committed Sep 6, 2021
1 parent 9f1b8b6 commit 1f270a9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
2 changes: 2 additions & 0 deletions integration-tests/salesforce/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
38 changes: 37 additions & 1 deletion integration-tests/salesforce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,11 @@ public String getTopicId() {

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public void configure() throws Exception {
+ "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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@

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 = ".+")
Expand Down Expand Up @@ -107,4 +110,13 @@ public void testCDCAndStreamingEvents() {
}
}

@Test
void testPlatformEvents() {
String event = given()
.contentType(ContentType.JSON)
.get("/salesforce/platform/event")
.asString();
assertTrue(event.contains("channel=/event/TestEvent__e"));
}

}

0 comments on commit 1f270a9

Please sign in to comment.