15
15
*/
16
16
package com .github .jcustenborder .kafka .connect .transform .common ;
17
17
18
- import com .google .common .base .CaseFormat ;
19
18
import com .google .common .collect .ImmutableMap ;
20
19
import org .apache .kafka .connect .connector .ConnectRecord ;
21
20
import org .apache .kafka .connect .data .Schema ;
24
23
import org .apache .kafka .connect .sink .SinkRecord ;
25
24
import org .apache .kafka .connect .transforms .Transformation ;
26
25
import org .junit .jupiter .api .Test ;
27
- import org .junit .jupiter .api .TestFactory ;
28
26
29
- import static com .github .jcustenborder .kafka .connect .utils .AssertSchema .assertSchema ;
30
- import static com .github .jcustenborder .kafka .connect .utils .AssertStruct .assertStruct ;
27
+ import java .util .LinkedHashMap ;
28
+ import java .util .Map ;
29
+
31
30
import static org .junit .jupiter .api .Assertions .assertEquals ;
32
31
import static org .junit .jupiter .api .Assertions .assertNotNull ;
33
32
@@ -37,7 +36,7 @@ protected ToJsonTest(boolean isKey) {
37
36
}
38
37
39
38
@ Test
40
- public void test () {
39
+ public void struct () {
41
40
this .transformation .configure (ImmutableMap .of ());
42
41
final Schema inputSchema = SchemaBuilder .struct ()
43
42
.field ("FIRST_NAME" , Schema .STRING_SCHEMA )
@@ -64,13 +63,32 @@ public void test() {
64
63
1L
65
64
);
66
65
67
- for (int i = 0 ; i < 50 ; i ++) {
68
- final SinkRecord transformedRecord = this .transformation .apply (inputRecord );
69
- assertNotNull (transformedRecord , "transformedRecord should not be null." );
70
- }
66
+ final SinkRecord transformedRecord = this .transformation .apply (inputRecord );
67
+ assertNotNull (transformedRecord , "transformedRecord should not be null." );
68
+ }
69
+
70
+ @ Test
71
+ public void map () {
72
+ this .transformation .configure (ImmutableMap .of ());
73
+ Map <String , String > input = new LinkedHashMap <>();
74
+ input .put ("FIRST_NAME" , "test" );
75
+ input .put ("LAST_NAME" , "user" );
76
+
77
+ final SinkRecord inputRecord = new SinkRecord (
78
+ "topic" ,
79
+ 1 ,
80
+ null ,
81
+ null ,
82
+ null ,
83
+ input ,
84
+ 1L
85
+ );
71
86
87
+ final SinkRecord transformedRecord = this .transformation .apply (inputRecord );
88
+ assertNotNull (transformedRecord , "transformedRecord should not be null." );
72
89
}
73
90
91
+
74
92
@ Test
75
93
public void ignoreNonStruct () {
76
94
final SinkRecord inputRecord = new SinkRecord (
0 commit comments