Skip to content

Commit

Permalink
MODLOGINKC-19: make non tenant topics optional (#120)
Browse files Browse the repository at this point in the history
* MODLOGINKC-19: make non tenant topics optional

* add test

* add using emptyIfNull util method
  • Loading branch information
yauhen-vavilkin authored Jul 2, 2024
1 parent eb3847a commit 6052efb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.folio.integration.kafka;

import static org.apache.commons.collections4.CollectionUtils.emptyIfNull;
import static org.folio.integration.kafka.KafkaUtils.getEnvTopicName;

import jakarta.annotation.PostConstruct;
Expand All @@ -17,7 +18,7 @@ public class KafkaTopicConfiguration {

@PostConstruct
public void createTopics() {
for (var topic : folioKafkaProperties.getTopics()) {
for (var topic : emptyIfNull(folioKafkaProperties.getTopics())) {
var topicName = getEnvTopicName(topic.getName());
var newTopic = KafkaUtils.createTopic(topicName, topic.getNumPartitions(), topic.getReplicationFactor());
kafkaAdminService.createTopic(newTopic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.folio.integration.kafka;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

import java.util.List;
Expand Down Expand Up @@ -34,4 +35,13 @@ void createTopics_positive() {
verify(kafkaAdminService).createTopic(new NewTopic("folio.topic2", Optional.empty(), Optional.of((short) 2)));
verify(kafkaAdminService).createTopic(new NewTopic("folio.topic3", Optional.of(30), Optional.of((short) -1)));
}

@Test
void createTopics_positive_topicsEmpty() {
when(folioKafkaProperties.getTopics()).thenReturn(null);

kafkaTopicConfiguration.createTopics();

verifyNoInteractions(kafkaAdminService);
}
}

0 comments on commit 6052efb

Please sign in to comment.