@@ -46,11 +46,11 @@ public void ParseSchema()
46
46
47
47
message ReferrerMessage {
48
48
49
- string root_id = 1 [(. confluent.field_meta) = { annotation : ""PII"" }];
50
- ReferencedMessage ref = 2 [(. confluent.field_meta).annotation = ""PII""];
49
+ string root_id = 1 [(confluent.field_meta) = { doc : ""PII"" }];
50
+ ReferencedMessage ref = 2 [(confluent.field_meta).doc = ""PII""];
51
51
52
52
}" ;
53
-
53
+
54
54
string import = @"syntax = ""proto3"";
55
55
package io.confluent.kafka.serializers.protobuf.test;
56
56
@@ -62,15 +62,20 @@ message ReferencedMessage {
62
62
63
63
IDictionary < string , string > imports = new Dictionary < string , string > ( ) ;
64
64
imports [ "ref.proto" ] = import ;
65
+ imports [ "confluent/meta.proto" ] = "doesn't matter, will be overwritten anyway" ;
65
66
66
67
var fds = ProtobufUtils . Parse ( schema , imports ) ;
67
- foreach ( var file in fds . Files )
68
- {
69
- foreach ( var messageType in file . MessageTypes )
70
- {
71
- Assert . Equal ( "ReferrerMessage" , messageType . Name ) ;
72
- }
73
- }
68
+ Assert . Equal ( 4 , fds . Files . Count ) ;
69
+
70
+ var fileNames = fds . Files . Select ( s => s . Name ) . ToHashSet ( ) ;
71
+ Assert . Contains ( "__root.proto" , fileNames ) ;
72
+ Assert . Contains ( "ref.proto" , fileNames ) ;
73
+ Assert . Contains ( "confluent/meta.proto" , fileNames ) ;
74
+ Assert . Contains ( "google/protobuf/descriptor.proto" , fileNames ) ;
75
+
76
+ var rootFile = fds . Files . First ( s => s . Name == "__root.proto" ) ;
77
+ Assert . Equal ( 1 , rootFile . MessageTypes . Count ) ;
78
+ Assert . Equal ( "ReferrerMessage" , rootFile . MessageTypes . First ( ) . Name ) ;
74
79
}
75
80
76
81
[ Fact ]
@@ -112,12 +117,12 @@ message Person {
112
117
schema . RuleSet = new RuleSet ( new List < Rule > ( ) ,
113
118
new List < Rule >
114
119
{
115
- new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL" , null , null ,
120
+ new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL" , null , null ,
116
121
"message.name == 'awesome'" , null , null , false )
117
122
}
118
123
) ;
119
124
store [ schemaStr ] = 1 ;
120
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
125
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
121
126
var config = new ProtobufSerializerConfig
122
127
{
123
128
AutoRegisterSchemas = false ,
@@ -159,12 +164,12 @@ message Person {
159
164
schema . RuleSet = new RuleSet ( new List < Rule > ( ) ,
160
165
new List < Rule >
161
166
{
162
- new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL" , null , null ,
167
+ new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL" , null , null ,
163
168
"message.name != 'awesome'" , null , null , false )
164
169
}
165
170
) ;
166
171
store [ schemaStr ] = 1 ;
167
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
172
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
168
173
var config = new ProtobufSerializerConfig
169
174
{
170
175
AutoRegisterSchemas = false ,
@@ -200,12 +205,12 @@ message Person {
200
205
schema . RuleSet = new RuleSet ( new List < Rule > ( ) ,
201
206
new List < Rule >
202
207
{
203
- new Rule ( "testCEL" , RuleKind . Transform , RuleMode . Write , "CEL_FIELD" , null , null ,
208
+ new Rule ( "testCEL" , RuleKind . Transform , RuleMode . Write , "CEL_FIELD" , null , null ,
204
209
"typeName == 'STRING' ; value + '-suffix'" , null , null , false )
205
210
}
206
211
) ;
207
212
store [ schemaStr ] = 1 ;
208
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
213
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
209
214
var config = new ProtobufSerializerConfig
210
215
{
211
216
AutoRegisterSchemas = false ,
@@ -247,12 +252,12 @@ message Person {
247
252
schema . RuleSet = new RuleSet ( new List < Rule > ( ) ,
248
253
new List < Rule >
249
254
{
250
- new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL_FIELD" , null , null ,
255
+ new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL_FIELD" , null , null ,
251
256
"name == 'name' ; value == 'awesome'" , null , null , false )
252
257
}
253
258
) ;
254
259
store [ schemaStr ] = 1 ;
255
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
260
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
256
261
var config = new ProtobufSerializerConfig
257
262
{
258
263
AutoRegisterSchemas = false ,
@@ -294,12 +299,12 @@ message Person {
294
299
schema . RuleSet = new RuleSet ( new List < Rule > ( ) ,
295
300
new List < Rule >
296
301
{
297
- new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL_FIELD" , null , null ,
302
+ new Rule ( "testCEL" , RuleKind . Condition , RuleMode . Write , "CEL_FIELD" , null , null ,
298
303
"name == 'name' ; value != 'awesome'" , null , null , false )
299
304
}
300
305
) ;
301
306
store [ schemaStr ] = 1 ;
302
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
307
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
303
308
var config = new ProtobufSerializerConfig
304
309
{
305
310
AutoRegisterSchemas = false ,
@@ -332,7 +337,7 @@ message PersonWithPic {
332
337
string name = 3 [(.confluent.field_meta) = { tags: ""PII"" }];
333
338
bytes picture = 4 [(.confluent.field_meta) = { tags: ""PII"" }];
334
339
}" ;
335
-
340
+
336
341
var schema = new RegisteredSchema ( "topic-value" , 1 , 1 , schemaStr , SchemaType . Protobuf , null ) ;
337
342
schema . Metadata = new Metadata ( new Dictionary < string , ISet < string > >
338
343
{
@@ -356,7 +361,7 @@ message PersonWithPic {
356
361
}
357
362
) ;
358
363
store [ schemaStr ] = 1 ;
359
- subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
364
+ subjectStore [ "topic-value" ] = new List < RegisteredSchema > { schema } ;
360
365
var config = new ProtobufSerializerConfig
361
366
{
362
367
AutoRegisterSchemas = false ,
0 commit comments