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

Send unique messages in Slack itest to avoid false positive tests #1604

Merged
merged 1 commit into from
Aug 25, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -54,8 +55,9 @@ public String getSlackMessages() throws Exception {

@Path("/message")
@POST
@Consumes(MediaType.TEXT_PLAIN)
public Response createSlackMessage(String message) throws Exception {
producerTemplate.requestBody("slack://general?" + SLACK_AUTH_PARAMS, "Hello Camel Quarkus Slack");
producerTemplate.requestBody("slack://general?" + SLACK_AUTH_PARAMS, message);
return Response
.created(new URI("https://camel.apache.org/"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package org.apache.camel.quarkus.component.slack.it;

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 static org.hamcrest.CoreMatchers.equalTo;
Expand All @@ -39,13 +42,21 @@ class SlackTest {

@Test
public void testSlackProduceConsumeMessages() {
RestAssured.post("/slack/message")
final String message = "Hello Camel Quarkus Slack" + (externalSlackEnabled() ? " " + UUID.randomUUID() : "");
RestAssured.given()
.contentType(ContentType.TEXT)
.body(message)
.post("/slack/message")
.then()
.statusCode(201);

RestAssured.get("/slack/messages")
.then()
.statusCode(200)
.body(equalTo("Hello Camel Quarkus Slack"));
.body(equalTo(message));
}

boolean externalSlackEnabled() {
return System.getenv("SLACK_WEBHOOK_URL") != null;
}
}