Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salesforce : add Platform events test fixes #2938 #3068

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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("{}")
zbendhiba marked this conversation as resolved.
Show resolved Hide resolved
.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"));
}

}