Skip to content

Commit

Permalink
test: add missing keys test
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrudevalia committed Jul 26, 2024
1 parent 33731ea commit ea373d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ConfigurationMigrator(private val settings: Map<String, String>) {

settings.forEach { (originalKey, value) ->
val propConverter = propertyConverterMap[originalKey]
if (propConverter != null) {
if (propConverter != null && propConverter.updatedConfigKey.isNotEmpty()) {
val newKey = propConverter.updatedConfigKey
updatedConfig[newKey] = propConverter.migrationHandler()
log.debug("Migrating configuration {} to {}", originalKey, newKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package streams.kafka.connect.sink
import org.junit.Assert.assertEquals
import org.junit.Test
import streams.kafka.connect.common.ConfigurationMigrator
import streams.kafka.connect.common.Neo4jConnectorConfig.Companion.ENCRYPTION_CA_CERTIFICATE_PATH
import streams.kafka.connect.source.Neo4jSourceConnectorConfig.Companion.ENFORCE_SCHEMA
import streams.kafka.connect.source.Neo4jSourceConnectorConfig.Companion.SOURCE_TYPE
import streams.kafka.connect.source.SourceType

class ConfigurationMigratorTest {

Expand All @@ -27,7 +31,20 @@ class ConfigurationMigratorTest {
)
}

@Test fun `should not migrate keys with no matching configuration key`() {}
@Test fun `should not migrate keys with no matching configuration key`() {
// Given a configuration which has no equivalent in the updated connector
val originals = mapOf(
ENCRYPTION_CA_CERTIFICATE_PATH to "./cert.pem",
SOURCE_TYPE to SourceType.QUERY.toString(),
ENFORCE_SCHEMA to "true"
)

// When the configuration is migrated
val migratedConfig = ConfigurationMigrator(originals).migrate()

// Then the existing key is not outputted
assertEquals("Migrated configuration should be empty", 0, migratedConfig.keys.size)
}

@Test
fun `should migrate time-based keys to new configuration format`() {
Expand Down

0 comments on commit ea373d8

Please sign in to comment.