/
KafkaConnectorTest.java
51 lines (40 loc) · 1.81 KB
/
KafkaConnectorTest.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
package io.quarkus.it.kafka;
import static io.restassured.RestAssured.get;
import static org.awaitility.Awaitility.await;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kafka.KafkaCompanionResource;
import io.restassured.common.mapper.TypeRef;
import io.restassured.response.Response;
import io.smallrye.reactive.messaging.kafka.commit.ProcessingState;
@QuarkusTest
@QuarkusTestResource(KafkaCompanionResource.class)
public class KafkaConnectorTest {
protected static final TypeRef<List<Person>> TYPE_REF = new TypeRef<List<Person>>() {
};
protected static final TypeRef<ProcessingState<KafkaReceivers.PeopleState>> PEOPLE_STATE_REF = new TypeRef<ProcessingState<KafkaReceivers.PeopleState>>() {
};
@Test
public void testPeople() {
await().untilAsserted(() -> Assertions.assertEquals(get("/kafka/people").as(TYPE_REF).size(), 6));
await().untilAsserted(() -> {
Response response = get("/kafka/people-state/{key}", "people-checkpoint:people:0");
Assertions.assertNotNull(response);
Assertions.assertTrue(response.asString().length() > 0);
ProcessingState<KafkaReceivers.PeopleState> state = response.as(PEOPLE_STATE_REF);
Assertions.assertNotNull(state);
Assertions.assertEquals("bob;alice;tom;jerry;anna;ken", state.getState().names);
});
}
@Test
public void testPets() {
await().untilAsserted(() -> Assertions.assertEquals(get("/kafka/pets").as(TYPE_REF).size(), 3));
}
@Test
public void testFruits() {
await().untilAsserted(() -> Assertions.assertEquals(get("/kafka/fruits").as(TYPE_REF).size(), 4));
}
}