-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Loïc Greffier
committed
Sep 19, 2023
1 parent
4d80b06
commit c74d39e
Showing
4 changed files
with
117 additions
and
19 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
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
101 changes: 101 additions & 0 deletions
101
kstreamplify-core/src/test/java/com/michelin/kstreamplify/utils/TopicWithSerdesTest.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,101 @@ | ||
package com.michelin.kstreamplify.utils; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.michelin.kstreamplify.context.KafkaStreamsExecutionContext; | ||
import java.util.Properties; | ||
import org.apache.kafka.common.serialization.Serdes; | ||
import org.apache.kafka.streams.StreamsBuilder; | ||
import org.apache.kafka.streams.kstream.KStream; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class TopicWithSerdesTest { | ||
|
||
@Test | ||
void shouldCreateTopicWithSerde() { | ||
KafkaStreamsExecutionContext.registerProperties(new Properties()); | ||
|
||
TopicWithSerde<String, String> topicWithSerde = new TopicWithSerde<>("INPUT_TOPIC", | ||
Serdes.String(), Serdes.String()); | ||
|
||
assertEquals("INPUT_TOPIC", topicWithSerde.getUnPrefixedName()); | ||
assertEquals("INPUT_TOPIC", topicWithSerde.toString()); | ||
} | ||
|
||
@Test | ||
void shouldCreateTopicWithSerdeWithPrefix() { | ||
Properties properties = new Properties(); | ||
properties.put("prefix.self", "abc."); | ||
|
||
KafkaStreamsExecutionContext.registerProperties(properties); | ||
|
||
TopicWithSerde<String, String> topicWithSerde = new TopicWithSerde<>("INPUT_TOPIC", | ||
Serdes.String(), Serdes.String()); | ||
|
||
assertEquals("INPUT_TOPIC", topicWithSerde.getUnPrefixedName()); | ||
assertEquals("abc.INPUT_TOPIC", topicWithSerde.toString()); | ||
} | ||
|
||
@Test | ||
void shouldCreateStream() { | ||
KafkaStreamsExecutionContext.registerProperties(new Properties()); | ||
|
||
TopicWithSerde<String, String> topicWithSerde = new TopicWithSerde<>("INPUT_TOPIC", | ||
Serdes.String(), Serdes.String()); | ||
|
||
StreamsBuilder streamsBuilder = new StreamsBuilder(); | ||
topicWithSerde.stream(streamsBuilder); | ||
|
||
assertEquals(""" | ||
Topologies: | ||
Sub-topology: 0 | ||
Source: KSTREAM-SOURCE-0000000000 (topics: [INPUT_TOPIC]) | ||
--> none | ||
""", streamsBuilder.build().describe().toString()); | ||
} | ||
|
||
@Test | ||
void shouldCreateTable() { | ||
KafkaStreamsExecutionContext.registerProperties(new Properties()); | ||
|
||
TopicWithSerde<String, String> topicWithSerde = new TopicWithSerde<>("INPUT_TOPIC", | ||
Serdes.String(), Serdes.String()); | ||
|
||
StreamsBuilder streamsBuilder = new StreamsBuilder(); | ||
topicWithSerde.table(streamsBuilder, "myStore"); | ||
|
||
assertEquals(""" | ||
Topologies: | ||
Sub-topology: 0 | ||
Source: KSTREAM-SOURCE-0000000000 (topics: [INPUT_TOPIC]) | ||
--> KTABLE-SOURCE-0000000001 | ||
Processor: KTABLE-SOURCE-0000000001 (stores: [myStore]) | ||
--> none | ||
<-- KSTREAM-SOURCE-0000000000 | ||
""", streamsBuilder.build().describe().toString()); | ||
} | ||
|
||
@Test | ||
void shouldCreateGKTable() { | ||
KafkaStreamsExecutionContext.registerProperties(new Properties()); | ||
|
||
TopicWithSerde<String, String> topicWithSerde = new TopicWithSerde<>("INPUT_TOPIC", | ||
Serdes.String(), Serdes.String()); | ||
|
||
StreamsBuilder streamsBuilder = new StreamsBuilder(); | ||
topicWithSerde.globalTable(streamsBuilder, "myStore"); | ||
|
||
assertEquals(""" | ||
Topologies: | ||
Sub-topology: 0 for global store (will not generate tasks) | ||
Source: KSTREAM-SOURCE-0000000000 (topics: [INPUT_TOPIC]) | ||
--> KTABLE-SOURCE-0000000001 | ||
Processor: KTABLE-SOURCE-0000000001 (stores: [myStore]) | ||
--> none | ||
<-- KSTREAM-SOURCE-0000000000 | ||
""", streamsBuilder.build().describe().toString()); | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
kstreamplify-core/src/test/java/com/michelin/kstreamplify/utils/TopicWithSerdesUnitTest.java
This file was deleted.
Oops, something went wrong.