Skip to content

Commit

Permalink
Send unique messages in Slack itest to avoid fail positive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
llowinge committed Aug 25, 2020
1 parent 173e7af commit ca5dbdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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,17 @@ class SlackTest {

@Test
public void testSlackProduceConsumeMessages() {
RestAssured.post("/slack/message")
final String message = "Hello Camel Quarkus Slack " + 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));
}
}

0 comments on commit ca5dbdd

Please sign in to comment.