// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }


import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import org.bson.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
        expectedKeyDocRegExpSettings.put("_F1",new BsonDocument("_F2",new BsonString("testing rocks!")));

        expectedValueDocRegExpSettings = new BsonDocument("abc",new BsonString("my field value"));
        expectedValueDocRegExpSettings.put("f2",new BsonBoolean(false));
        expectedValueDocRegExpSettings.put("subDoc",new BsonDocument("123",new BsonDouble(0.0)));
        expectedValueDocRegExpSettings.put("foo_foo_foo",new BsonDocument("_blah__blah_",new BsonInt32(23)));
    }

    @BeforeAll
    public static void setupRenamerSettings() {
        fieldnameMappings = new HashMap<>();
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".fieldA","f1");
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".f2","fieldB");
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".subDoc.fieldX","name_x");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".abc","xyz");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".f2","f_two");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".subDoc.123","789");

        regExpSettings = new HashMap<>();
        regExpSettings.put("^"+Renamer.PATH_PREFIX_KEY+"\\..*my.*$",new RenameByRegExp.PatternReplace("my",""));
        regExpSettings.put("^"+Renamer.PATH_PREFIX_KEY+"\\..*field.*$",new RenameByRegExp.PatternReplace("field","F"));
        regExpSettings.put("^"+Renamer.PATH_PREFIX_VALUE+"\\..*$",new RenameByRegExp.PatternReplace("\\.","_"));
    }



    @Test
    @DisplayName("simple field renamer test with custom field name mappings")
    public void testRenamerUsingFieldnameMapping() {

// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }


// Path: src/test/java/at/grahsl/kafka/connect/mongodb/processor/field/renaming/RenamerTest.java
import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import org.bson.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;

        expectedKeyDocRegExpSettings.put("_F1",new BsonDocument("_F2",new BsonString("testing rocks!")));

        expectedValueDocRegExpSettings = new BsonDocument("abc",new BsonString("my field value"));
        expectedValueDocRegExpSettings.put("f2",new BsonBoolean(false));
        expectedValueDocRegExpSettings.put("subDoc",new BsonDocument("123",new BsonDouble(0.0)));
        expectedValueDocRegExpSettings.put("foo_foo_foo",new BsonDocument("_blah__blah_",new BsonInt32(23)));
    }

    @BeforeAll
    public static void setupRenamerSettings() {
        fieldnameMappings = new HashMap<>();
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".fieldA","f1");
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".f2","fieldB");
        fieldnameMappings.put(Renamer.PATH_PREFIX_KEY+".subDoc.fieldX","name_x");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".abc","xyz");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".f2","f_two");
        fieldnameMappings.put(Renamer.PATH_PREFIX_VALUE+".subDoc.123","789");

        regExpSettings = new HashMap<>();
        regExpSettings.put("^"+Renamer.PATH_PREFIX_KEY+"\\..*my.*$",new RenameByRegExp.PatternReplace("my",""));
        regExpSettings.put("^"+Renamer.PATH_PREFIX_KEY+"\\..*field.*$",new RenameByRegExp.PatternReplace("field","F"));
        regExpSettings.put("^"+Renamer.PATH_PREFIX_VALUE+"\\..*$",new RenameByRegExp.PatternReplace("\\.","_"));
    }



    @Test
    @DisplayName("simple field renamer test with custom field name mappings")
    public void testRenamerUsingFieldnameMapping() {

        SinkDocument sd = new SinkDocument(keyDoc, valueDoc);