-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for that sources are mapped to GroupedTopics correctly
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
connectors/kafka/src/test/java/forklift/connectors/KafkaConnectorTests.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,58 @@ | ||
package forklift.connectors; | ||
|
||
import forklift.source.sources.GroupedTopicSource; | ||
import forklift.source.sources.QueueSource; | ||
import forklift.source.sources.TopicSource; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class KafkaConnectorTests { | ||
private static final String GROUP_ID = "test-default"; | ||
private KafkaConnector connector; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
connector = new KafkaConnector("blah", "blah", GROUP_ID); | ||
} | ||
|
||
@Test | ||
public void testQueueMapping() { | ||
final String topicName = "test-topic"; | ||
|
||
final GroupedTopicSource mappedSource = connector.mapToGroupedTopic(new QueueSource(topicName)); | ||
Assert.assertEquals(new GroupedTopicSource(topicName, GROUP_ID), mappedSource); | ||
} | ||
|
||
@Test | ||
public void testTopicMapping() { | ||
final String topicName = "test-topic"; | ||
final TopicSource consumerSource = new TopicSource(topicName); | ||
consumerSource.setContextClass(FakeConsumer.class); | ||
|
||
final GroupedTopicSource mappedConsumerSource = connector.mapToGroupedTopic(consumerSource); | ||
Assert.assertEquals(new GroupedTopicSource(topicName, "test-default-FakeConsumer"), mappedConsumerSource); | ||
} | ||
|
||
@Test | ||
public void testDefaultTopicMapping() { | ||
final String topicName = "test-topic"; | ||
final TopicSource anonymousSource = new TopicSource(topicName); | ||
|
||
final GroupedTopicSource mappedConsumerSource = connector.mapToGroupedTopic(anonymousSource); | ||
Assert.assertEquals(new GroupedTopicSource(topicName, GROUP_ID), mappedConsumerSource); | ||
} | ||
|
||
@Test | ||
public void testGroupedTopicMapping() { | ||
final String topicName = "test-topic"; | ||
final String groupId = "test-group"; | ||
final GroupedTopicSource unmappedSource = new GroupedTopicSource(topicName, groupId); | ||
|
||
final GroupedTopicSource mappedSource = connector.mapToGroupedTopic(unmappedSource); | ||
Assert.assertEquals(unmappedSource, mappedSource); | ||
} | ||
|
||
private final class FakeConsumer {} | ||
} |