forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-3943 Add ConfigDef unit tests to verify all Debezium Field instan…
…ces have a proper documentation/description set; Also adding missing descriptions.
- Loading branch information
Showing
13 changed files
with
225 additions
and
3 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
15 changes: 15 additions & 0 deletions
15
...or-mongodb/src/test/java/io/debezium/connector/mongodb/MongoDbConnectorConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.mongodb; | ||
|
||
import io.debezium.config.ConfigDefinitionMetadataTest; | ||
|
||
public class MongoDbConnectorConfigDefTest extends ConfigDefinitionMetadataTest { | ||
|
||
public MongoDbConnectorConfigDefTest() { | ||
super(new MongoDbConnector()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ngodb/src/test/java/io/debezium/connector/mongodb/MongoDbTransformationConfigDefTest.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,16 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.mongodb; | ||
|
||
import io.debezium.config.TransformationConfigDefinitionMetadataTest; | ||
import io.debezium.connector.mongodb.transforms.ExtractNewDocumentState; | ||
|
||
public class MongoDbTransformationConfigDefTest extends TransformationConfigDefinitionMetadataTest { | ||
|
||
public MongoDbTransformationConfigDefTest() { | ||
super(new ExtractNewDocumentState<>()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...onnector-mysql/src/test/java/io/debezium/connector/mysql/MySqlConnectorConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.mysql; | ||
|
||
import io.debezium.config.ConfigDefinitionMetadataTest; | ||
|
||
public class MySqlConnectorConfigDefTest extends ConfigDefinitionMetadataTest { | ||
|
||
public MySqlConnectorConfigDefTest() { | ||
super(new MySqlConnector()); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...ector-oracle/src/test/java/io/debezium/connector/oracle/OracleConnectorConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.oracle; | ||
|
||
import io.debezium.config.ConfigDefinitionMetadataTest; | ||
|
||
public class OracleConnectorConfigDefTest extends ConfigDefinitionMetadataTest { | ||
|
||
public OracleConnectorConfigDefTest() { | ||
super(new OracleConnector()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...stgres/src/test/java/io/debezium/connector/postgresql/PostgresConnectorConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.postgresql; | ||
|
||
import io.debezium.config.ConfigDefinitionMetadataTest; | ||
|
||
public class PostgresConnectorConfigDefTest extends ConfigDefinitionMetadataTest { | ||
|
||
public PostgresConnectorConfigDefTest() { | ||
super(new PostgresConnector()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...server/src/test/java/io/debezium/connector/sqlserver/SqlServerConnectorConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.sqlserver; | ||
|
||
import io.debezium.config.ConfigDefinitionMetadataTest; | ||
|
||
public class SqlServerConnectorConfigDefTest extends ConfigDefinitionMetadataTest { | ||
|
||
public SqlServerConnectorConfigDefTest() { | ||
super(new SqlServerConnector()); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
debezium-core/src/test/java/io/debezium/config/ConfigDefinitionMetadataTest.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,37 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.config; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
import java.util.Map.Entry; | ||
|
||
import org.apache.kafka.common.config.ConfigDef; | ||
import org.apache.kafka.common.config.ConfigDef.ConfigKey; | ||
import org.apache.kafka.connect.source.SourceConnector; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Applies basic checks of completeness for the connector-specific configuration metadata. | ||
*/ | ||
public abstract class ConfigDefinitionMetadataTest { | ||
|
||
private final ConfigDef config; | ||
|
||
protected ConfigDefinitionMetadataTest(SourceConnector connector) { | ||
this.config = connector.config(); | ||
} | ||
|
||
@Test | ||
public void allFieldsShouldHaveDescription() { | ||
for (Entry<String, ConfigKey> configKey : config.configKeys().entrySet()) { | ||
assertThat(configKey.getValue().documentation) | ||
.describedAs("Description of config key \"" + configKey.getKey() + "\"") | ||
.isNotNull() | ||
.isNotEmpty(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...core/src/test/java/io/debezium/config/CoreTransformationConfigDefinitionMetadataTest.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,25 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.config; | ||
|
||
import io.debezium.transforms.ByLogicalTableRouter; | ||
import io.debezium.transforms.ExtractNewRecordState; | ||
import io.debezium.transforms.outbox.EventRouter; | ||
import io.debezium.transforms.tracing.ActivateTracingSpan; | ||
|
||
/** | ||
* Applies basic checks of completeness of the SMT-specific configuration metadata for the Debezium core SMTs. | ||
*/ | ||
public class CoreTransformationConfigDefinitionMetadataTest extends TransformationConfigDefinitionMetadataTest { | ||
|
||
public CoreTransformationConfigDefinitionMetadataTest() { | ||
super( | ||
new ByLogicalTableRouter<>(), | ||
new ExtractNewRecordState<>(), | ||
new EventRouter<>(), | ||
new ActivateTracingSpan<>()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ium-core/src/test/java/io/debezium/config/TransformationConfigDefinitionMetadataTest.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,43 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.config; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Map.Entry; | ||
import java.util.Set; | ||
|
||
import org.apache.kafka.common.config.ConfigDef.ConfigKey; | ||
import org.apache.kafka.connect.transforms.Transformation; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Applies basic checks of completeness for the SMT-specific configuration metadata. | ||
*/ | ||
public abstract class TransformationConfigDefinitionMetadataTest { | ||
|
||
private final Set<Transformation<?>> transforms; | ||
|
||
public TransformationConfigDefinitionMetadataTest(Transformation<?>... transforms) { | ||
Set<Transformation<?>> tmp = new HashSet<>(); | ||
Collections.addAll(tmp, transforms); | ||
this.transforms = Collections.unmodifiableSet(tmp); | ||
} | ||
|
||
@Test | ||
public void allFieldsShouldHaveDescription() { | ||
for (Transformation<?> transformation : transforms) { | ||
for (Entry<String, ConfigKey> configKey : transformation.config().configKeys().entrySet()) { | ||
assertThat(configKey.getValue().documentation) | ||
.describedAs("Description of config key \"" + configKey.getKey() + "\" of transform class " + transformation.getClass().getName()) | ||
.isNotNull() | ||
.isNotEmpty(); | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...-scripting/src/test/java/io/debezium/transforms/ScriptingTransformationConfigDefTest.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,15 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.transforms; | ||
|
||
import io.debezium.config.TransformationConfigDefinitionMetadataTest; | ||
|
||
public class ScriptingTransformationConfigDefTest extends TransformationConfigDefinitionMetadataTest { | ||
|
||
public ScriptingTransformationConfigDefTest() { | ||
super(new Filter<>(), new ContentBasedRouter<>()); | ||
} | ||
} |