/*
Copyright [2018] [jc3wish]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package driver

import (
	"runtime"
	"strings"
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

var DebeziumInsertData, DebeziumUpdateData map[string]string

func init() {
	DebeziumInsertData = map[string]string{
		"key":   `{"schema":{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"}],"optional":false,"name":"debezium_.bifrost_test.binlog_field_test.Key"},"payload":{"id":1}}`,
		"value": `{"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"},{"type":"int16","optional":false,"default":-1,"field":"testtinyint"},{"type":"int16","optional":false,"default":-2,"field":"testsmallint"},{"type":"int32","optional":false,"default":-3,"field":"testmediumint"},{"type":"int32","optional":false,"default":-4,"field":"testint"},{"type":"int64","optional":false,"default":-5,"field":"testbigint"},{"type":"string","optional":false,"field":"testvarchar"},{"type":"string","optional":false,"field":"testchar"},{"type":"string","optional":false,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"default":"en1","field":"testenum"},{"type":"string","optional":false,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"default":"set1","field":"testset"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"default":0,"field":"testtime"},{"type":"int32","optional":false,"name":"io.debezium.time.Date","version":1,"default":0,"field":"testdate"},{"type":"int32","optional":false,"name":"io.debezium.time.Year","version":1,"default":1989,"field":"testyear"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"default":0,"field":"testdatetime"},{"type":"double","optional":false,"default":0.0,"field":"testfloat"},{"type":"double","optional":false,"default":0.0,"field":"testdouble"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"default":"AA==","field":"testdecimal"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"default":"AA==","field":"testdecimal2"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"default":"AA==","field":"testdecimal3"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"default":"AA==","field":"testdecimal4"},{"type":"string","optional":false,"field":"testtext"},{"type":"bytes","optional":false,"field":"testblob"},{"type":"bytes","optional":false,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"default":"AA==","field":"testbit"},{"type":"int16","optional":false,"default":0,"field":"testbool"},{"type":"bytes","optional":false,"field":"testmediumblob"},{"type":"bytes","optional":false,"field":"testlongblob"},{"type":"bytes","optional":false,"field":"testtinyblob"},{"type":"int16","optional":false,"default":1,"field":"test_unsinged_tinyint"},{"type":"int32","optional":false,"default":2,"field":"test_unsinged_smallint"},{"type":"int32","optional":false,"default":3,"field":"test_unsinged_mediumint"},{"type":"int64","optional":false,"default":4,"field":"test_unsinged_int"},{"type":"int64","optional":false,"default":5,"field":"test_unsinged_bigint"},{"type":"int16","optional":true,"field":"testtinyint_null"},{"type":"int16","optional":true,"field":"testsmallint_null"},{"type":"int32","optional":true,"field":"testmediumint_null"},{"type":"int32","optional":true,"field":"testint_null"},{"type":"int64","optional":true,"field":"testbigint_null"},{"type":"string","optional":true,"field":"testvarchar_null"},{"type":"string","optional":true,"field":"testchar_null"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"field":"testenum_null"},{"type":"string","optional":true,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"field":"testset_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Date","version":1,"field":"testdate_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Year","version":1,"field":"testyear_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime_null"},{"type":"double","optional":true,"field":"testfloat_null"},{"type":"double","optional":true,"field":"testdouble_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"field":"testdecimal_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"field":"testdecimal2_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"field":"testdecimal3_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"field":"testdecimal4_null"},{"type":"string","optional":true,"field":"testtext_null"},{"type":"bytes","optional":true,"field":"testblob_null"},{"type":"bytes","optional":true,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"field":"testbit_null"},{"type":"int16","optional":true,"field":"testbool_null"},{"type":"bytes","optional":true,"field":"testmediumblob_null"},{"type":"bytes","optional":true,"field":"testlongblob_null"},{"type":"bytes","optional":true,"field":"testtinyblob_null"},{"type":"int16","optional":true,"field":"test_unsinged_tinyint_null"},{"type":"int32","optional":true,"field":"test_unsinged_smallint_null"},{"type":"int32","optional":true,"field":"test_unsinged_mediumint_null"},{"type":"int64","optional":true,"field":"test_unsinged_int_null"},{"type":"int64","optional":true,"field":"test_unsinged_bigint_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_1"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_2"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_3"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_4"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_5"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_6"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_1_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_2_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_3_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_4_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_5_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_6_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6_null"},{"type":"string","optional":false,"name":"io.debezium.data.Json","version":1,"field":"test_json"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"test_json_null"}],"optional":true,"name":"debezium_.bifrost_test.binlog_field_test.Value","field":"before"},{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"},{"type":"int16","optional":false,"default":-1,"field":"testtinyint"},{"type":"int16","optional":false,"default":-2,"field":"testsmallint"},{"type":"int32","optional":false,"default":-3,"field":"testmediumint"},{"type":"int32","optional":false,"default":-4,"field":"testint"},{"type":"int64","optional":false,"default":-5,"field":"testbigint"},{"type":"string","optional":false,"field":"testvarchar"},{"type":"string","optional":false,"field":"testchar"},{"type":"string","optional":false,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"default":"en1","field":"testenum"},{"type":"string","optional":false,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"default":"set1","field":"testset"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"default":0,"field":"testtime"},{"type":"int32","optional":false,"name":"io.debezium.time.Date","version":1,"default":0,"field":"testdate"},{"type":"int32","optional":false,"name":"io.debezium.time.Year","version":1,"default":1989,"field":"testyear"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"default":0,"field":"testdatetime"},{"type":"double","optional":false,"default":0.0,"field":"testfloat"},{"type":"double","optional":false,"default":0.0,"field":"testdouble"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"default":"AA==","field":"testdecimal"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"default":"AA==","field":"testdecimal2"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"default":"AA==","field":"testdecimal3"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"default":"AA==","field":"testdecimal4"},{"type":"string","optional":false,"field":"testtext"},{"type":"bytes","optional":false,"field":"testblob"},{"type":"bytes","optional":false,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"default":"AA==","field":"testbit"},{"type":"int16","optional":false,"default":0,"field":"testbool"},{"type":"bytes","optional":false,"field":"testmediumblob"},{"type":"bytes","optional":false,"field":"testlongblob"},{"type":"bytes","optional":false,"field":"testtinyblob"},{"type":"int16","optional":false,"default":1,"field":"test_unsinged_tinyint"},{"type":"int32","optional":false,"default":2,"field":"test_unsinged_smallint"},{"type":"int32","optional":false,"default":3,"field":"test_unsinged_mediumint"},{"type":"int64","optional":false,"default":4,"field":"test_unsinged_int"},{"type":"int64","optional":false,"default":5,"field":"test_unsinged_bigint"},{"type":"int16","optional":true,"field":"testtinyint_null"},{"type":"int16","optional":true,"field":"testsmallint_null"},{"type":"int32","optional":true,"field":"testmediumint_null"},{"type":"int32","optional":true,"field":"testint_null"},{"type":"int64","optional":true,"field":"testbigint_null"},{"type":"string","optional":true,"field":"testvarchar_null"},{"type":"string","optional":true,"field":"testchar_null"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"field":"testenum_null"},{"type":"string","optional":true,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"field":"testset_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Date","version":1,"field":"testdate_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Year","version":1,"field":"testyear_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime_null"},{"type":"double","optional":true,"field":"testfloat_null"},{"type":"double","optional":true,"field":"testdouble_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"field":"testdecimal_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"field":"testdecimal2_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"field":"testdecimal3_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"field":"testdecimal4_null"},{"type":"string","optional":true,"field":"testtext_null"},{"type":"bytes","optional":true,"field":"testblob_null"},{"type":"bytes","optional":true,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"field":"testbit_null"},{"type":"int16","optional":true,"field":"testbool_null"},{"type":"bytes","optional":true,"field":"testmediumblob_null"},{"type":"bytes","optional":true,"field":"testlongblob_null"},{"type":"bytes","optional":true,"field":"testtinyblob_null"},{"type":"int16","optional":true,"field":"test_unsinged_tinyint_null"},{"type":"int32","optional":true,"field":"test_unsinged_smallint_null"},{"type":"int32","optional":true,"field":"test_unsinged_mediumint_null"},{"type":"int64","optional":true,"field":"test_unsinged_int_null"},{"type":"int64","optional":true,"field":"test_unsinged_bigint_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_1"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_2"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_3"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_4"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_5"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_6"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_1_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_2_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_3_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_4_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_5_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_6_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6_null"},{"type":"string","optional":false,"name":"io.debezium.data.Json","version":1,"field":"test_json"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"test_json_null"}],"optional":true,"name":"debezium_.bifrost_test.binlog_field_test.Value","field":"after"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false,incremental"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":true,"field":"sequence"},{"type":"string","optional":true,"field":"table"},{"type":"int64","optional":false,"field":"server_id"},{"type":"string","optional":true,"field":"gtid"},{"type":"string","optional":false,"field":"file"},{"type":"int64","optional":false,"field":"pos"},{"type":"int32","optional":false,"field":"row"},{"type":"int64","optional":true,"field":"thread"},{"type":"string","optional":true,"field":"query"}],"optional":false,"name":"io.debezium.connector.mysql.Source","field":"source"},{"type":"string","optional":false,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"id"},{"type":"int64","optional":false,"field":"total_order"},{"type":"int64","optional":false,"field":"data_collection_order"}],"optional":true,"name":"event.block","version":1,"field":"transaction"}],"optional":false,"name":"debezium_.bifrost_test.binlog_field_test.Envelope","version":1},"payload":{"before":null,"after":{"id":1,"testtinyint":100,"testsmallint":32767,"testmediumint":8388607,"testint":-2147483648,"testbigint":9223372036854775807,"testvarchar":"3Qa]Eq数","testchar":"","testenum":"en1","testset":"set1,set3","testtime":65191000000,"testdate":19280,"testyear":2022,"testtimestamp":"2022-10-15T10:06:31Z","testdatetime":1665857191000,"testfloat":16737.919921875,"testdouble":260298.21,"testdecimal":"K89/PA==","testdecimal2":"/2FyQM8=","testdecimal3":"Av6fpC3a5qd6","testdecimal4":"FnlPPldsV6ykag==","testtext":"rM2TEf}6<E测试试数测试数试测据测据据据试数据测数","testblob":"Iw==","testbit":"bA==","testbool":1,"testmediumblob":"PF5UM2dwQEVvNk1URw==","testlongblob":"QWxjPzNibTFzTDA=","testtinyblob":"Mk1zMH05Wi9OSF9WP1NNYWZFb2QhfGBLfDkuInot","test_unsinged_tinyint":255,"test_unsinged_smallint":65535,"test_unsinged_mediumint":16777215,"test_unsinged_int":4294967295,"test_unsinged_bigint":1844674407370955161,"testtinyint_null":null,"testsmallint_null":null,"testmediumint_null":null,"testint_null":null,"testbigint_null":null,"testvarchar_null":null,"testchar_null":null,"testenum_null":null,"testset_null":null,"testtime_null":null,"testdate_null":null,"testyear_null":null,"testtimestamp_null":null,"testdatetime_null":null,"testfloat_null":null,"testdouble_null":null,"testdecimal_null":null,"testdecimal2_null":null,"testdecimal3_null":null,"testdecimal4_null":null,"testtext_null":null,"testblob_null":null,"testbit_null":null,"testbool_null":null,"testmediumblob_null":null,"testlongblob_null":null,"testtinyblob_null":null,"test_unsinged_tinyint_null":null,"test_unsinged_smallint_null":null,"test_unsinged_mediumint_null":null,"test_unsinged_int_null":null,"test_unsinged_bigint_null":null,"testtime2_1":null,"testtime2_2":65191090000,"testtime2_3":65191098000,"testtime2_4":65191098000,"testtime2_5":65191098300,"testtime2_6":65191098335,"testtimestamp2_1":"2022-10-15T10:06:31Z","testtimestamp2_2":"2022-10-15T10:06:31Z","testtimestamp2_3":"2022-10-15T10:06:31.098Z","testtimestamp2_4":"2022-10-15T10:06:31.098Z","testtimestamp2_5":"2022-10-15T10:06:31.0985Z","testtimestamp2_6":"2022-10-15T10:06:31.09863Z","testdatetime2_1":1665857191000,"testdatetime2_2":1665857191090,"testdatetime2_3":1665857191090,"testdatetime2_4":1665857191098000,"testdatetime2_5":1665857191098790,"testdatetime2_6":1665857191098890,"testtime2_1_null":null,"testtime2_2_null":null,"testtime2_3_null":null,"testtime2_4_null":null,"testtime2_5_null":null,"testtime2_6_null":null,"testtimestamp2_1_null":null,"testtimestamp2_2_null":null,"testtimestamp2_3_null":null,"testtimestamp2_4_null":null,"testtimestamp2_5_null":null,"testtimestamp2_6_null":null,"testdatetime2_1_null":null,"testdatetime2_2_null":null,"testdatetime2_3_null":null,"testdatetime2_4_null":null,"testdatetime2_5_null":null,"testdatetime2_6_null":null,"test_json":"{\"key1\": [2147483647, -2147483648, \"2\", null, true, 922337203685477, -922337203685477, {\"key2\": \"qoYuY,Np5Q\\\\OpX9&'o8试测测试据试数数数试试测据试测测\"}, {\"key2\": false}]}","test_json_null":null},"source":{"version":"2.0.0.Final","connector":"mysql","name":"debezium_","ts_ms":1666085684000,"snapshot":"last","db":"bifrost_test","sequence":null,"table":"binlog_field_test","server_id":0,"gtid":null,"file":"mysql-bin.000004","pos":1796,"row":0,"thread":null,"query":null},"op":"r","ts_ms":1666085684916,"transaction":null}}`,
	}

	DebeziumUpdateData = map[string]string{
		"key":   `{"schema":{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"}],"optional":false,"name":"debezium_.bifrost_test.binlog_field_test.Key"},"payload":{"id":1}}`,
		"value": `{"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"},{"type":"int16","optional":false,"default":-1,"field":"testtinyint"},{"type":"int16","optional":false,"default":-2,"field":"testsmallint"},{"type":"int32","optional":false,"default":-3,"field":"testmediumint"},{"type":"int32","optional":false,"default":-4,"field":"testint"},{"type":"int64","optional":false,"default":-5,"field":"testbigint"},{"type":"string","optional":false,"field":"testvarchar"},{"type":"string","optional":false,"field":"testchar"},{"type":"string","optional":false,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"default":"en1","field":"testenum"},{"type":"string","optional":false,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"default":"set1","field":"testset"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"default":0,"field":"testtime"},{"type":"int32","optional":false,"name":"io.debezium.time.Date","version":1,"default":0,"field":"testdate"},{"type":"int32","optional":false,"name":"io.debezium.time.Year","version":1,"default":1989,"field":"testyear"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"default":0,"field":"testdatetime"},{"type":"double","optional":false,"default":0.0,"field":"testfloat"},{"type":"double","optional":false,"default":0.0,"field":"testdouble"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"default":"AA==","field":"testdecimal"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"default":"AA==","field":"testdecimal2"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"default":"AA==","field":"testdecimal3"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"default":"AA==","field":"testdecimal4"},{"type":"string","optional":false,"field":"testtext"},{"type":"bytes","optional":false,"field":"testblob"},{"type":"bytes","optional":false,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"default":"AA==","field":"testbit"},{"type":"int16","optional":false,"default":0,"field":"testbool"},{"type":"bytes","optional":false,"field":"testmediumblob"},{"type":"bytes","optional":false,"field":"testlongblob"},{"type":"bytes","optional":false,"field":"testtinyblob"},{"type":"int16","optional":false,"default":1,"field":"test_unsinged_tinyint"},{"type":"int32","optional":false,"default":2,"field":"test_unsinged_smallint"},{"type":"int32","optional":false,"default":3,"field":"test_unsinged_mediumint"},{"type":"int64","optional":false,"default":4,"field":"test_unsinged_int"},{"type":"int64","optional":false,"default":5,"field":"test_unsinged_bigint"},{"type":"int16","optional":true,"field":"testtinyint_null"},{"type":"int16","optional":true,"field":"testsmallint_null"},{"type":"int32","optional":true,"field":"testmediumint_null"},{"type":"int32","optional":true,"field":"testint_null"},{"type":"int64","optional":true,"field":"testbigint_null"},{"type":"string","optional":true,"field":"testvarchar_null"},{"type":"string","optional":true,"field":"testchar_null"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"field":"testenum_null"},{"type":"string","optional":true,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"field":"testset_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Date","version":1,"field":"testdate_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Year","version":1,"field":"testyear_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime_null"},{"type":"double","optional":true,"field":"testfloat_null"},{"type":"double","optional":true,"field":"testdouble_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"field":"testdecimal_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"field":"testdecimal2_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"field":"testdecimal3_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"field":"testdecimal4_null"},{"type":"string","optional":true,"field":"testtext_null"},{"type":"bytes","optional":true,"field":"testblob_null"},{"type":"bytes","optional":true,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"field":"testbit_null"},{"type":"int16","optional":true,"field":"testbool_null"},{"type":"bytes","optional":true,"field":"testmediumblob_null"},{"type":"bytes","optional":true,"field":"testlongblob_null"},{"type":"bytes","optional":true,"field":"testtinyblob_null"},{"type":"int16","optional":true,"field":"test_unsinged_tinyint_null"},{"type":"int32","optional":true,"field":"test_unsinged_smallint_null"},{"type":"int32","optional":true,"field":"test_unsinged_mediumint_null"},{"type":"int64","optional":true,"field":"test_unsinged_int_null"},{"type":"int64","optional":true,"field":"test_unsinged_bigint_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_1"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_2"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_3"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_4"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_5"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_6"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_1_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_2_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_3_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_4_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_5_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_6_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6_null"},{"type":"string","optional":false,"name":"io.debezium.data.Json","version":1,"field":"test_json"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"test_json_null"}],"optional":true,"name":"debezium_.bifrost_test.binlog_field_test.Value","field":"before"},{"type":"struct","fields":[{"type":"int64","optional":false,"field":"id"},{"type":"int16","optional":false,"default":-1,"field":"testtinyint"},{"type":"int16","optional":false,"default":-2,"field":"testsmallint"},{"type":"int32","optional":false,"default":-3,"field":"testmediumint"},{"type":"int32","optional":false,"default":-4,"field":"testint"},{"type":"int64","optional":false,"default":-5,"field":"testbigint"},{"type":"string","optional":false,"field":"testvarchar"},{"type":"string","optional":false,"field":"testchar"},{"type":"string","optional":false,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"default":"en1","field":"testenum"},{"type":"string","optional":false,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"default":"set1","field":"testset"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"default":0,"field":"testtime"},{"type":"int32","optional":false,"name":"io.debezium.time.Date","version":1,"default":0,"field":"testdate"},{"type":"int32","optional":false,"name":"io.debezium.time.Year","version":1,"default":1989,"field":"testyear"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"default":0,"field":"testdatetime"},{"type":"double","optional":false,"default":0.0,"field":"testfloat"},{"type":"double","optional":false,"default":0.0,"field":"testdouble"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"default":"AA==","field":"testdecimal"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"default":"AA==","field":"testdecimal2"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"default":"AA==","field":"testdecimal3"},{"type":"bytes","optional":false,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"default":"AA==","field":"testdecimal4"},{"type":"string","optional":false,"field":"testtext"},{"type":"bytes","optional":false,"field":"testblob"},{"type":"bytes","optional":false,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"default":"AA==","field":"testbit"},{"type":"int16","optional":false,"default":0,"field":"testbool"},{"type":"bytes","optional":false,"field":"testmediumblob"},{"type":"bytes","optional":false,"field":"testlongblob"},{"type":"bytes","optional":false,"field":"testtinyblob"},{"type":"int16","optional":false,"default":1,"field":"test_unsinged_tinyint"},{"type":"int32","optional":false,"default":2,"field":"test_unsinged_smallint"},{"type":"int32","optional":false,"default":3,"field":"test_unsinged_mediumint"},{"type":"int64","optional":false,"default":4,"field":"test_unsinged_int"},{"type":"int64","optional":false,"default":5,"field":"test_unsinged_bigint"},{"type":"int16","optional":true,"field":"testtinyint_null"},{"type":"int16","optional":true,"field":"testsmallint_null"},{"type":"int32","optional":true,"field":"testmediumint_null"},{"type":"int32","optional":true,"field":"testint_null"},{"type":"int64","optional":true,"field":"testbigint_null"},{"type":"string","optional":true,"field":"testvarchar_null"},{"type":"string","optional":true,"field":"testchar_null"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"en1,en2,en3"},"field":"testenum_null"},{"type":"string","optional":true,"name":"io.debezium.data.EnumSet","version":1,"parameters":{"allowed":"set1,set2,set3"},"field":"testset_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Date","version":1,"field":"testdate_null"},{"type":"int32","optional":true,"name":"io.debezium.time.Year","version":1,"field":"testyear_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime_null"},{"type":"double","optional":true,"field":"testfloat_null"},{"type":"double","optional":true,"field":"testdouble_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"2","connect.decimal.precision":"9"},"field":"testdecimal_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"10"},"field":"testdecimal2_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"4","connect.decimal.precision":"20"},"field":"testdecimal3_null"},{"type":"bytes","optional":true,"name":"org.apache.kafka.connect.data.Decimal","version":1,"parameters":{"scale":"5","connect.decimal.precision":"30"},"field":"testdecimal4_null"},{"type":"string","optional":true,"field":"testtext_null"},{"type":"bytes","optional":true,"field":"testblob_null"},{"type":"bytes","optional":true,"name":"io.debezium.data.Bits","version":1,"parameters":{"length":"8"},"field":"testbit_null"},{"type":"int16","optional":true,"field":"testbool_null"},{"type":"bytes","optional":true,"field":"testmediumblob_null"},{"type":"bytes","optional":true,"field":"testlongblob_null"},{"type":"bytes","optional":true,"field":"testtinyblob_null"},{"type":"int16","optional":true,"field":"test_unsinged_tinyint_null"},{"type":"int32","optional":true,"field":"test_unsinged_smallint_null"},{"type":"int32","optional":true,"field":"test_unsinged_mediumint_null"},{"type":"int64","optional":true,"field":"test_unsinged_int_null"},{"type":"int64","optional":true,"field":"test_unsinged_bigint_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_1"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_2"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_3"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_4"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_5"},{"type":"string","optional":false,"name":"io.debezium.time.ZonedTimestamp","version":1,"default":"1970-01-01T00:00:00Z","field":"testtimestamp2_6"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2"},{"type":"int64","optional":false,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5"},{"type":"int64","optional":false,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTime","version":1,"field":"testtime2_6_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_1_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_2_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_3_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_4_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_5_null"},{"type":"string","optional":true,"name":"io.debezium.time.ZonedTimestamp","version":1,"field":"testtimestamp2_6_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_1_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_2_null"},{"type":"int64","optional":true,"name":"io.debezium.time.Timestamp","version":1,"field":"testdatetime2_3_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_4_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_5_null"},{"type":"int64","optional":true,"name":"io.debezium.time.MicroTimestamp","version":1,"field":"testdatetime2_6_null"},{"type":"string","optional":false,"name":"io.debezium.data.Json","version":1,"field":"test_json"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"test_json_null"}],"optional":true,"name":"debezium_.bifrost_test.binlog_field_test.Value","field":"after"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false,incremental"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":true,"field":"sequence"},{"type":"string","optional":true,"field":"table"},{"type":"int64","optional":false,"field":"server_id"},{"type":"string","optional":true,"field":"gtid"},{"type":"string","optional":false,"field":"file"},{"type":"int64","optional":false,"field":"pos"},{"type":"int32","optional":false,"field":"row"},{"type":"int64","optional":true,"field":"thread"},{"type":"string","optional":true,"field":"query"}],"optional":false,"name":"io.debezium.connector.mysql.Source","field":"source"},{"type":"string","optional":false,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"id"},{"type":"int64","optional":false,"field":"total_order"},{"type":"int64","optional":false,"field":"data_collection_order"}],"optional":true,"name":"event.block","version":1,"field":"transaction"}],"optional":false,"name":"debezium_.bifrost_test.binlog_field_test.Envelope","version":1},"payload":{"before":{"id":1,"testtinyint":100,"testsmallint":32767,"testmediumint":8388607,"testint":-2147483648,"testbigint":9223372036854775807,"testvarchar":"3Qa]Eq数","testchar":"","testenum":"en1","testset":"set1,set3","testtime":65191000000,"testdate":19280,"testyear":2022,"testtimestamp":"2022-10-15T10:06:31Z","testdatetime":1665857191000,"testfloat":16737.919921875,"testdouble":260298.21,"testdecimal":"K89/PA==","testdecimal2":"/2FyQM8=","testdecimal3":"Av6fpC3a5qd6","testdecimal4":"FnlPPldsV6ykag==","testtext":"rM2TEf}6<E测试试数测试数试测据测据据据试数据测数","testblob":"Iw==","testbit":"bA==","testbool":1,"testmediumblob":"PF5UM2dwQEVvNk1URw==","testlongblob":"QWxjPzNibTFzTDA=","testtinyblob":"Mk1zMH05Wi9OSF9WP1NNYWZFb2QhfGBLfDkuInot","test_unsinged_tinyint":255,"test_unsinged_smallint":65535,"test_unsinged_mediumint":16777215,"test_unsinged_int":4294967295,"test_unsinged_bigint":1844674407370955161,"testtinyint_null":null,"testsmallint_null":null,"testmediumint_null":null,"testint_null":null,"testbigint_null":null,"testvarchar_null":null,"testchar_null":null,"testenum_null":null,"testset_null":null,"testtime_null":null,"testdate_null":null,"testyear_null":null,"testtimestamp_null":null,"testdatetime_null":null,"testfloat_null":null,"testdouble_null":null,"testdecimal_null":null,"testdecimal2_null":null,"testdecimal3_null":null,"testdecimal4_null":null,"testtext_null":null,"testblob_null":null,"testbit_null":null,"testbool_null":null,"testmediumblob_null":null,"testlongblob_null":null,"testtinyblob_null":null,"test_unsinged_tinyint_null":null,"test_unsinged_smallint_null":null,"test_unsinged_mediumint_null":null,"test_unsinged_int_null":null,"test_unsinged_bigint_null":null,"testtime2_1":null,"testtime2_2":65191090000,"testtime2_3":65191098000,"testtime2_4":65191098000,"testtime2_5":65191098300,"testtime2_6":65191098335,"testtimestamp2_1":"2022-10-15T10:06:31Z","testtimestamp2_2":"2022-10-15T10:06:31Z","testtimestamp2_3":"2022-10-15T10:06:31.098Z","testtimestamp2_4":"2022-10-15T10:06:31.098Z","testtimestamp2_5":"2022-10-15T10:06:31.0985Z","testtimestamp2_6":"2022-10-15T10:06:31.09863Z","testdatetime2_1":1665857191000,"testdatetime2_2":1665857191090,"testdatetime2_3":1665857191090,"testdatetime2_4":1665857191098000,"testdatetime2_5":1665857191098790,"testdatetime2_6":1665857191098890,"testtime2_1_null":null,"testtime2_2_null":null,"testtime2_3_null":null,"testtime2_4_null":null,"testtime2_5_null":null,"testtime2_6_null":null,"testtimestamp2_1_null":null,"testtimestamp2_2_null":null,"testtimestamp2_3_null":null,"testtimestamp2_4_null":null,"testtimestamp2_5_null":null,"testtimestamp2_6_null":null,"testdatetime2_1_null":null,"testdatetime2_2_null":null,"testdatetime2_3_null":null,"testdatetime2_4_null":null,"testdatetime2_5_null":null,"testdatetime2_6_null":null,"test_json":"{\"key1\":[2147483647,-2147483648,\"2\",null,true,922337203685477,-922337203685477,{\"key2\":\"qoYuY,Np5Q\\\\OpX9&'o8试测测试据试数数数试试测据试测测\"},{\"key2\":false}]}","test_json_null":null},"after":{"id":1,"testtinyint":99,"testsmallint":32767,"testmediumint":8388607,"testint":-2147483648,"testbigint":9223372036854775807,"testvarchar":"3Qa]Eq数","testchar":"","testenum":"en1","testset":"set1,set3","testtime":65191000000,"testdate":19280,"testyear":2022,"testtimestamp":"2022-10-15T10:06:31Z","testdatetime":1665857191000,"testfloat":16737.919921875,"testdouble":260298.21,"testdecimal":"K89/PA==","testdecimal2":"/2FyQM8=","testdecimal3":"Av6fpC3a5qd6","testdecimal4":"FnlPPldsV6ykag==","testtext":"rM2TEf}6<E测试试数测试数试测据测据据据试数据测数","testblob":"Iw==","testbit":"bA==","testbool":1,"testmediumblob":"PF5UM2dwQEVvNk1URw==","testlongblob":"QWxjPzNibTFzTDA=","testtinyblob":"Mk1zMH05Wi9OSF9WP1NNYWZFb2QhfGBLfDkuInot","test_unsinged_tinyint":255,"test_unsinged_smallint":65535,"test_unsinged_mediumint":16777215,"test_unsinged_int":4294967295,"test_unsinged_bigint":1844674407370955161,"testtinyint_null":null,"testsmallint_null":null,"testmediumint_null":null,"testint_null":null,"testbigint_null":null,"testvarchar_null":null,"testchar_null":null,"testenum_null":null,"testset_null":null,"testtime_null":null,"testdate_null":null,"testyear_null":null,"testtimestamp_null":null,"testdatetime_null":null,"testfloat_null":null,"testdouble_null":null,"testdecimal_null":null,"testdecimal2_null":null,"testdecimal3_null":null,"testdecimal4_null":null,"testtext_null":null,"testblob_null":null,"testbit_null":null,"testbool_null":null,"testmediumblob_null":null,"testlongblob_null":null,"testtinyblob_null":null,"test_unsinged_tinyint_null":null,"test_unsinged_smallint_null":null,"test_unsinged_mediumint_null":null,"test_unsinged_int_null":null,"test_unsinged_bigint_null":null,"testtime2_1":null,"testtime2_2":65191090000,"testtime2_3":65191098000,"testtime2_4":65191098000,"testtime2_5":65191098300,"testtime2_6":65191098335,"testtimestamp2_1":"2022-10-15T10:06:31Z","testtimestamp2_2":"2022-10-15T10:06:31Z","testtimestamp2_3":"2022-10-15T10:06:31.098Z","testtimestamp2_4":"2022-10-15T10:06:31.098Z","testtimestamp2_5":"2022-10-15T10:06:31.0985Z","testtimestamp2_6":"2022-10-15T10:06:31.09863Z","testdatetime2_1":1665857191000,"testdatetime2_2":1665857191090,"testdatetime2_3":1665857191090,"testdatetime2_4":1665857191098000,"testdatetime2_5":1665857191098790,"testdatetime2_6":1665857191098890,"testtime2_1_null":null,"testtime2_2_null":null,"testtime2_3_null":null,"testtime2_4_null":null,"testtime2_5_null":null,"testtime2_6_null":null,"testtimestamp2_1_null":null,"testtimestamp2_2_null":null,"testtimestamp2_3_null":null,"testtimestamp2_4_null":null,"testtimestamp2_5_null":null,"testtimestamp2_6_null":null,"testdatetime2_1_null":null,"testdatetime2_2_null":null,"testdatetime2_3_null":null,"testdatetime2_4_null":null,"testdatetime2_5_null":null,"testdatetime2_6_null":null,"test_json":"{\"key1\":[2147483647,-2147483648,\"2\",null,true,922337203685477,-922337203685477,{\"key2\":\"qoYuY,Np5Q\\\\OpX9&'o8试测测试据试数数数试试测据试测测\"},{\"key2\":false}]}","test_json_null":null},"source":{"version":"2.0.0.Final","connector":"mysql","name":"debezium_","ts_ms":1666094367000,"snapshot":"false","db":"bifrost_test","sequence":null,"table":"binlog_field_test","server_id":1,"gtid":"71bc9d8e-4c74-11ed-9cbb-0242ac11000b:14","file":"mysql-bin.000004","pos":2777,"row":0,"thread":5,"query":null},"op":"u","ts_ms":1666094367089,"transaction":null}}`,
	}
}

func TestNewDebezium(t *testing.T) {
	t.Log(runtime.Version())
	Convey("NewDebeziumInsert", t, func() {
		c, err := NewDebezium([]byte(DebeziumInsertData["key"]), []byte(DebeziumInsertData["value"]))
		So(err, ShouldEqual, nil)
		So(c, ShouldNotEqual, nil)
		bifrostEventData := c.ToBifrostOutputPluginData()
		So(bifrostEventData, ShouldNotEqual, nil)
		So(bifrostEventData.EventType, ShouldEqual, "insert")
		So(bifrostEventData.Rows[0]["id"], ShouldEqual, int64(1))
	})

	Convey("NewDebeziumUpdate", t, func() {
		c, err := NewDebezium([]byte(DebeziumUpdateData["key"]), []byte(DebeziumUpdateData["value"]))
		So(err, ShouldEqual, nil)
		So(c, ShouldNotEqual, nil)
		bifrostEventData := c.ToBifrostOutputPluginData()
		So(bifrostEventData, ShouldNotEqual, nil)
		So(bifrostEventData.EventType, ShouldEqual, "update")
		So(bifrostEventData.Rows[0]["id"], ShouldEqual, int64(1))

		So(bifrostEventData.Rows[1]["testchar"], ShouldEqual, "")
		So(bifrostEventData.Rows[1]["testenum"], ShouldEqual, "en1")
		So(bifrostEventData.Rows[1]["testtimestamp"], ShouldEqual, "2022-10-15 10:06:31")
		So(strings.Contains(bifrostEventData.Rows[1]["test_json"].(string), "\\\""), ShouldEqual, false)
		So(bifrostEventData.Rows[1]["testblob"], ShouldEqual, "Iw==")
		So(bifrostEventData.Rows[1]["testdate"], ShouldEqual, "2022-10-15")
		So(bifrostEventData.Rows[1]["testtime"], ShouldEqual, "18:06:31")
		So(bifrostEventData.Rows[1]["testtime2_6"], ShouldEqual, "18:06:31.098335")
		So(bifrostEventData.Rows[1]["testtime2_5"], ShouldEqual, "18:06:31.098300")
		So(bifrostEventData.Rows[1]["testenum"], ShouldEqual, "en1")
		So(bifrostEventData.Rows[1]["testset"], ShouldEqual, "set1,set3")
	})
}
