-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathSqsResourcesTest.java
54 lines (47 loc) · 1.82 KB
/
SqsResourcesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.acme.sqs;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.any;
import static org.hamcrest.Matchers.containsString;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response.Status;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
@QuarkusTestResource(SqsResource.class)
public class SqsResourcesTest {
private static final BiFunction<String, String, String> QUARK = (flavor, spin) -> String
.format("{\"flavor\":\"%s\", \"spin\":\"%s\"}", flavor, spin);
@ParameterizedTest
@ValueSource(strings = {"sync", "async"})
void testResource(final String testedResource) {
List<String> quarks = Arrays.asList("Charm", "Strange", "Bottom", "Upper");
//Fire quarks
quarks.forEach(quark -> {
given()
.pathParam("resource", testedResource)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.body(QUARK.apply(quark, "1/2"))
.when()
.post("/{resource}/cannon/shoot")
.then()
.statusCode(Status.OK.getStatusCode())
.body(any(String.class));
});
//Read quarks from the queue
given()
.pathParam("resource", testedResource)
.when()
.get("/{resource}/shield")
.then()
.statusCode(Status.OK.getStatusCode())
.body(containsString("Charm"),
containsString("Strange"),
containsString("Bottom"));
}
}