-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update consumer groups client to a new model with group name
- Loading branch information
1 parent
ffc65ff
commit bf33182
Showing
6 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
public record ConsumerGroup( | ||
Long id, | ||
String name, | ||
Long partitionsCount, | ||
Long membersCount | ||
) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/rs/iggy/consumergroup/ConsumerGroupsClientBaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package rs.iggy.consumergroup; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import rs.iggy.IntegrationTest; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public abstract class ConsumerGroupsClientBaseTest extends IntegrationTest { | ||
|
||
protected ConsumerGroupsClient consumerGroupsClient; | ||
|
||
@BeforeEach | ||
void beforeEachBase() { | ||
consumerGroupsClient = client.consumerGroups(); | ||
|
||
login(); | ||
} | ||
|
||
@Test | ||
void shouldCreateAndDeleteConsumerGroup() { | ||
// given | ||
setUpStreamAndTopic(); | ||
|
||
// when | ||
consumerGroupsClient.createConsumerGroup(42L, 42L, 42L, "consumer-group-42"); | ||
|
||
var consumerGroupById = consumerGroupsClient.getConsumerGroup(42L, 42L, 42L); | ||
var consumerGroupByName = consumerGroupsClient.getConsumerGroup(42L, 42L, 42L); | ||
|
||
// then | ||
assertThat(consumerGroupById).isNotNull(); | ||
assertThat(consumerGroupById.id()).isEqualTo(42L); | ||
assertThat(consumerGroupById.name()).isEqualTo("consumer-group-42"); | ||
assertThat(consumerGroupById).isEqualTo(consumerGroupByName); | ||
|
||
// when | ||
consumerGroupsClient.deleteConsumerGroup(42L, 42L, 42L); | ||
|
||
// then | ||
assertThat(consumerGroupsClient.getConsumerGroups(42L, 42L)).isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldDeleteConsumerGroupByName() { | ||
// given | ||
setUpStreamAndTopic(); | ||
consumerGroupsClient.createConsumerGroup(42L, 42L, 42L, "consumer-group-42"); | ||
var consumerGroup = consumerGroupsClient.getConsumerGroup(42L, 42L, 42L); | ||
assert consumerGroup != null; | ||
|
||
// when | ||
consumerGroupsClient.deleteConsumerGroup(42L, 42L, "consumer-group-42"); | ||
|
||
// then | ||
assertThat(consumerGroupsClient.getConsumerGroups(42L, 42L)).isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldGetAllConsumerGroups() { | ||
// given | ||
setUpStreamAndTopic(); | ||
|
||
consumerGroupsClient.createConsumerGroup(42L, 42L, 42L, "consumer-group-42"); | ||
consumerGroupsClient.createConsumerGroup(42L, 42L, 43L, "consumer-group-43"); | ||
consumerGroupsClient.createConsumerGroup(42L, 42L, 44L, "consumer-group-44"); | ||
|
||
// when | ||
var consumerGroups = consumerGroupsClient.getConsumerGroups(42L, 42L); | ||
|
||
// then | ||
assertThat(consumerGroups).hasSize(3); | ||
assertThat(consumerGroups) | ||
.map(ConsumerGroup::name) | ||
.containsExactlyInAnyOrder("consumer-group-42", "consumer-group-43", "consumer-group-44"); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/test/java/rs/iggy/http/ConsumerGroupsHttpClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package rs.iggy.http; | ||
|
||
import rs.iggy.IggyClient; | ||
import rs.iggy.consumergroup.ConsumerGroupsClientBaseTest; | ||
|
||
class ConsumerGroupsHttpClientTest extends ConsumerGroupsClientBaseTest { | ||
|
||
@Override | ||
protected IggyClient getClient() { | ||
return HttpClientFactory.create(iggyServer); | ||
} | ||
|
||
} |