DBZ-5779 Migrated debezium-connector-mongodb to AssertJ

This commit is contained in:
jcechace 2022-11-01 20:37:06 +01:00 committed by Jiri Pechanec
parent 1573684292
commit f91963f59d
38 changed files with 59 additions and 60 deletions

View File

@ -64,8 +64,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.LinkedList;

View File

@ -7,7 +7,7 @@
import static io.debezium.connector.mongodb.JsonSerialization.COMPACT_JSON_SETTINGS;
import static io.debezium.data.Envelope.FieldName.AFTER;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.Collections;

View File

@ -7,7 +7,7 @@
import static io.debezium.connector.mongodb.JsonSerialization.COMPACT_JSON_SETTINGS;
import static io.debezium.data.Envelope.FieldName.AFTER;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.Collections;

View File

@ -7,7 +7,7 @@
import static io.debezium.connector.mongodb.JsonSerialization.COMPACT_JSON_SETTINGS;
import static io.debezium.data.Envelope.FieldName.AFTER;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.time.Duration;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import org.bson.Document;

View File

@ -23,10 +23,9 @@
import org.apache.kafka.connect.data.Struct;
import org.apache.kafka.connect.source.SourceRecord;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.bson.Document;
import org.fest.assertions.Assertions;
import org.fest.assertions.MapAssert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -343,7 +342,7 @@ public void snapshotOnly() throws Exception {
final int expectedRecordCount = ROW_COUNT;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -359,7 +358,7 @@ public void invalidTablesInTheList() throws Exception {
final int expectedRecordCount = ROW_COUNT;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -393,7 +392,7 @@ public void snapshotOnlyWithRestart() throws Exception {
}
});
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -411,7 +410,7 @@ public void inserts() throws Exception {
final int expectedRecordCount = ROW_COUNT * 2;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -430,7 +429,7 @@ public void updates() throws Exception {
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount,
x -> x.getValue() >= 2000, null);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i + 2000));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i + 2000));
}
}
@ -466,7 +465,7 @@ public void updatesWithRestart() throws Exception {
}
});
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i + 2000));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i + 2000));
}
}
@ -485,7 +484,7 @@ public void updatesLargeChunk() throws Exception {
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount,
x -> x.getValue() >= 2000, null);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i + 2000));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i + 2000));
}
}
@ -527,7 +526,7 @@ public void stopCurrentIncrementalSnapshotWithoutCollectionsAndTakeNewNewIncreme
final int expectedRecordCount = ROW_COUNT * 2;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -569,7 +568,7 @@ public void stopCurrentIncrementalSnapshotWithAllCollectionsAndTakeNewNewIncreme
final int expectedRecordCount = ROW_COUNT * 2;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount);
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -602,7 +601,7 @@ public void removeNotYetCapturedCollectionFromInProgressIncrementalSnapshot() th
final int expectedRecordCount = ROW_COUNT * 2;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount, topicName());
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -638,7 +637,7 @@ public void removeStartedCapturedCollectionFromInProgressIncrementalSnapshot() t
final int expectedRecordCount = ROW_COUNT * 2;
final Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount, topicNames.get(1));
for (int i = 0; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}
@ -672,7 +671,7 @@ public void pauseDuringSnapshot() throws Exception {
final int expectedRecordCount = ROW_COUNT;
Map<Integer, Integer> dbChanges = consumeMixedWithIncrementalSnapshot(expectedRecordCount - beforeResume);
for (int i = beforeResume + 1; i < expectedRecordCount; i++) {
Assertions.assertThat(dbChanges).includes(MapAssert.entry(i + 1, i));
Assertions.assertThat(dbChanges).contains(Assertions.entry(i + 1, i));
}
}

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;

View File

@ -8,7 +8,7 @@
import static io.debezium.connector.mongodb.JsonSerialization.COMPACT_JSON_SETTINGS;
import static io.debezium.junit.EqualityCheck.LESS_THAN;
import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException;
@ -1948,7 +1948,7 @@ public void shouldReplicateContent() throws Exception {
start(MongoDbConnector.class, config);
waitForStreamingRunning("mongodb", "mongo");
final Object[] expectedNames = { "Jon Snow", "Sally Hamm" };
final List<String> expectedNames = List.of("Jon Snow", "Sally Hamm");
primary().execute("shouldAddMoreRecordsToContacts", mongo -> {
MongoDatabase db = mongo.getDatabase("dbA");
MongoCollection<Document> contacts = db.getCollection("contacts");
@ -1967,7 +1967,7 @@ public void shouldReplicateContent() throws Exception {
}
}
assertThat(foundNames).containsOnly(expectedNames);
assertThat(foundNames).containsOnlyElementsOf(expectedNames);
});
// Consume records
@ -1986,7 +1986,7 @@ public void shouldReplicateContent() throws Exception {
assertThat(operation == Operation.READ || operation == Operation.CREATE).isTrue();
});
assertNoRecordsToConsume();
assertThat(foundNames).containsOnly(expectedNames);
assertThat(foundNames).containsOnlyElementsOf(expectedNames);
// Stop connector
stopConnector();
@ -2060,8 +2060,8 @@ public void shouldReplicateContent() throws Exception {
assertThat(operation).isEqualTo(Operation.READ);
});
final Object[] allExpectedNames = { "Sally Hamm" };
assertThat(foundNames).containsOnly(allExpectedNames);
final List<String> allExpectedNames = List.of("Sally Hamm");
assertThat(foundNames).containsOnlyElementsOf(allExpectedNames);
waitForStreamingRunning("mongodb", "mongo");
assertNoRecordsToConsume();

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.fail;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Test;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.lang.management.ManagementFactory;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;

View File

@ -6,7 +6,7 @@
package io.debezium.connector.mongodb;
import static io.debezium.data.VerifyRecord.assertConnectSchemasAreEqual;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map;

View File

@ -15,11 +15,11 @@
import java.util.function.Consumer;
import org.apache.kafka.connect.data.Struct;
import org.assertj.core.api.Assertions;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.fest.assertions.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -5,9 +5,9 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.fest.assertions.StringAssert;
import org.assertj.core.api.AbstractStringAssert;
import org.junit.Before;
import org.junit.Test;
@ -43,7 +43,7 @@ public void shouldHandleCollectionIdWithInvalidTopicNameChar() {
assertTopic(withPrefix, dbAndCollection("db", "my@collection")).isEqualTo("prefix.db.my_collection");
}
protected StringAssert assertTopic(TopicSelector<CollectionId> selector, CollectionId collectionId) {
protected AbstractStringAssert<?> assertTopic(TopicSelector<CollectionId> selector, CollectionId collectionId) {
return assertThat(selector.topicNameFor(collectionId));
}

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;

View File

@ -8,7 +8,7 @@
import static io.debezium.junit.EqualityCheck.GREATER_THAN_OR_EQUAL;
import static io.debezium.junit.EqualityCheck.LESS_THAN;
import static io.debezium.junit.SkipWhenKafkaVersion.KafkaVersion.KAFKA_241;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.time.Instant;
@ -26,10 +26,10 @@
import org.apache.kafka.connect.errors.DataException;
import org.apache.kafka.connect.header.Header;
import org.apache.kafka.connect.source.SourceRecord;
import org.assertj.core.api.Assertions;
import org.bson.Document;
import org.bson.RawBsonDocument;
import org.bson.types.ObjectId;
import org.fest.assertions.Assertions;
import org.junit.Test;
import io.debezium.connector.mongodb.MongoDbFieldName;

View File

@ -6,7 +6,7 @@
package io.debezium.connector.mongodb.transforms;
import static io.debezium.connector.mongodb.TestHelper.lines;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map.Entry;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.net.URISyntaxException;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.net.URISyntaxException;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms.UpdateOperators;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.function.Consumer;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms.UpdateOperators;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms.UpdateOperators;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.connect.data.Struct;

View File

@ -5,7 +5,7 @@
*/
package io.debezium.connector.mongodb.transforms.UpdateOperators;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.function.Consumer;

View File

@ -7,7 +7,7 @@
import static io.debezium.connector.mongodb.MongoDbSchema.UPDATED_DESCRIPTION_SCHEMA;
import static org.apache.kafka.connect.transforms.util.Requirements.requireStruct;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.nio.charset.StandardCharsets;
import java.time.Instant;

View File

@ -6,7 +6,7 @@
package io.debezium.connector.mongodb.transforms.outbox;
import static org.apache.kafka.connect.transforms.util.Requirements.requireStruct;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.Collections;