fix(sync): 修复null字符串=null的识别

This commit is contained in:
v-zhangjc9
2024-06-17 18:48:49 +08:00
parent ef983f9eb7
commit 4ffcfe3ab5
2 changed files with 16 additions and 22 deletions

View File

@@ -10,8 +10,15 @@ import org.apache.hudi.org.apache.avro.Schema;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.*;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_BOOLEAN_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_DECIMAL_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_DOUBLE_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_FLOAT_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_INT_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_LONG_SCHEMA;
import static com.lanyuanxiaoyao.service.sync.functions.type.TypeConverterV2.NULLABLE_STRING_SCHEMA;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
@@ -91,6 +98,11 @@ public class TypeConvertTest {
// null
assertNull(convertValue.exec(NULLABLE_BOOLEAN_SCHEMA, "test", null));
assertNull(convertValue.exec(NULLABLE_STRING_SCHEMA, "test", "null"));
assertNull(convertValue.exec(NULLABLE_STRING_SCHEMA, "test", "NULL"));
assertNull(convertValue.exec(NULLABLE_STRING_SCHEMA, "test", null));
assertNull(convertValue.exec(NULLABLE_STRING_SCHEMA, "test", ""));
assertNotNull(convertValue.exec(NULLABLE_STRING_SCHEMA, "test", "Null"));
// boolean
assertEquals(true, convertValue.exec(NULLABLE_BOOLEAN_SCHEMA, "test", "true"));