-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConsumerOffsetsClientBaseTest.java
50 lines (41 loc) · 1.54 KB
/
ConsumerOffsetsClientBaseTest.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
package rs.iggy.clients.blocking;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import rs.iggy.consumergroup.Consumer;
import rs.iggy.identifier.ConsumerId;
import rs.iggy.identifier.StreamId;
import rs.iggy.identifier.TopicId;
import java.math.BigInteger;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
public abstract class ConsumerOffsetsClientBaseTest extends IntegrationTest {
ConsumerOffsetsClient consumerOffsetsClient;
@BeforeEach
void beforeEachBase() {
consumerOffsetsClient = client.consumerOffsets();
login();
setUpStreamAndTopic();
}
@Test
void shouldGetConsumerOffset() {
// when
var consumer = new Consumer(Consumer.Kind.Consumer, ConsumerId.of(1223L));
consumerOffsetsClient.storeConsumerOffset(StreamId.of(42L),
TopicId.of(42L),
Optional.empty(),
consumer,
BigInteger.ZERO);
var consumerOffset = consumerOffsetsClient.getConsumerOffset(StreamId.of(42L),
TopicId.of(42L),
Optional.of(1L),
consumer);
var nonExistingConsumerOffset = consumerOffsetsClient.getConsumerOffset(StreamId.of(42L),
TopicId.of(42L),
Optional.of(2L),
new Consumer(
Consumer.Kind.Consumer, ConsumerId.of(123L)));
// then
assertThat(consumerOffset).isPresent();
assertThat(nonExistingConsumerOffset).isEmpty();
}
}