Skip to content

Commit

Permalink
Update Salesforce testCDCAndStreamingEvents test to wait for consumin…
Browse files Browse the repository at this point in the history
…g the right Document

Fixes #3103
  • Loading branch information
zbendhiba authored and aldettinger committed Sep 19, 2021
1 parent 1137e00 commit f4f992f
Showing 1 changed file with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/
package org.apache.camel.quarkus.component.salesforce;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
Expand All @@ -25,8 +27,7 @@
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.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -59,25 +60,31 @@ public void testCDCAndStreamingEvents() {
.asString();

// Verify we captured the account creation event
RestAssured.given()
.get("/salesforce/cdc")
.then()
.statusCode(200)
.body("Name", is(accountName));
await().atMost(30, TimeUnit.SECONDS).until(() -> {
Map result = RestAssured.given()
.get("/salesforce/cdc")
.body()
.as(Map.class);
return result != null && accountName.equals(result.get(("Name")));
});

// Verify we can stream the Account as Object
RestAssured.given()
.get("/salesforce/streaming")
.then()
.statusCode(200)
.body(equalTo(accountName));
await().atMost(30, TimeUnit.SECONDS).until(() -> {
String result = RestAssured.given()
.get("/salesforce/streaming")
.body()
.asString();
return accountName.equals(result);
});

// Verify we can stream the Account as Raw payload
RestAssured.given()
.get("/salesforce/streaming/raw")
.then()
.statusCode(200)
.body("Name", equalTo(accountName));
await().atMost(30, TimeUnit.SECONDS).until(() -> {
String result = RestAssured.given()
.get("/salesforce/streaming/raw")
.body()
.asString();
return result != null && result.contains(accountName);
});

// Get the topic ID
topicId = RestAssured.given()
Expand Down

0 comments on commit f4f992f

Please sign in to comment.