Skip to content

Commit

Permalink
IKC-304 Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Belke authored and Piotr Belke committed Oct 21, 2023
1 parent 5414af8 commit 39a0afc
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.consdata.kouncil.KafkaConnectionService;
import java.util.stream.IntStream;
import org.junit.Ignore;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -14,8 +13,12 @@

@SpringBootTest
@DirtiesContext
@EmbeddedKafka(partitions = 4, bootstrapServersProperty =
"spring.kafka.bootstrap-servers", brokerProperties = {"listeners=PLAINTEXT://localhost:59092", "port=59092"}, ports = 59092)
@EmbeddedKafka(
partitions = 4,
bootstrapServersProperty = "spring.kafka.bootstrap-servers",
brokerProperties = {"listeners=PLAINTEXT://localhost:59092", "port=59092"},
ports = 59092
)
class TopicServiceTest {

@Autowired
Expand All @@ -30,22 +33,22 @@ class TopicServiceTest {
private static final String BOOSTRAP_SERVER = "localhost_59092";

@Test
@Ignore
void should_fetch_all_generated_messages() {
IntStream.range(0, 100).forEach(index -> kafkaTemplate.send("embedded-test-topic", String.format("Msg no %s", index)));
kafkaConnectionService.getAdminClient(BOOSTRAP_SERVER);

TopicMessagesDto topicMessages = topicService.getTopicMessages("embedded-test-topic", "all", "1", "100", null, null, null, BOOSTRAP_SERVER);
TopicMessagesDto topicMessages = topicService.getTopicMessages("embedded-test-topic", "all", "1", "100",
null, null, null, BOOSTRAP_SERVER);
assertThat(topicMessages.getMessages()).hasSize(100);
}

@Test
@Ignore
void should_fetch_all_generated_messages_small_amount() {
IntStream.range(0, 2).forEach(index -> kafkaTemplate.send("embedded-test-topic-2", String.format("Msg no %s", index)));
kafkaConnectionService.getAdminClient(BOOSTRAP_SERVER);

TopicMessagesDto topicMessages = topicService.getTopicMessages("embedded-test-topic-2", "all", "1", "10", null, null, null, BOOSTRAP_SERVER);
TopicMessagesDto topicMessages = topicService.getTopicMessages("embedded-test-topic-2", "all", "1", "10",
null, null, null, BOOSTRAP_SERVER);
assertThat(topicMessages.getMessages()).hasSize(2);
}
}

0 comments on commit 39a0afc

Please sign in to comment.