@@ -122,21 +122,27 @@ public void setUp() throws Exception {
122
122
MockitoAnnotations .initMocks (this );
123
123
124
124
consumer = new MockConsumer <>(OffsetResetStrategy .EARLIEST );
125
- ConsumerRecord <String , TopicResultSet > record1 = createConsumerRecord ("myTopic" , 0 , "k1" , createTopicResultSet ("myTopic" ));
126
- ConsumerRecord <String , TopicResultSet > record2 = createConsumerRecord ("myTopic" , 0 , "k2" , createTopicResultSet ("myTopic" ));
125
+ ConsumerRecord <String , TopicResultSet > record1 = createConsumerRecord ("myTopic" , 0 , 0 , "k1" , createTopicResultSet ("myTopic" ));
126
+ ConsumerRecord <String , TopicResultSet > record2 = createConsumerRecord ("myTopic" , 0 , 1 , "k2" , createTopicResultSet ("myTopic" ));
127
+ ConsumerRecord <String , TopicResultSet > nullValueRecord = createConsumerRecord ("myTopic" , 0 , 2 , "k3" , null );
127
128
consumer .schedulePollTask (() -> {
128
129
consumer .addRecord (record1 );
129
130
consumer .addRecord (record2 );
131
+ consumer .addRecord (nullValueRecord );
130
132
});
131
133
avroConsumer = new MockConsumer <>(OffsetResetStrategy .EARLIEST );
132
- ConsumerRecord <String , GenericRecord > avroRecord = createAvroConsumerRecord ("greetings" , 0 , "k1" , createGenericRecord ("greetings" ));
134
+ ConsumerRecord <String , GenericRecord > avroRecord = createAvroConsumerRecord ("greetings" , 0 , 0 , "k1" , createGenericRecord ("greetings" ));
135
+ ConsumerRecord <String , GenericRecord > avroNullValueRecord = createAvroConsumerRecord ("greetings" , 0 , 1 , "k2" , null );
133
136
avroConsumer .schedulePollTask (() -> {
134
137
avroConsumer .addRecord (avroRecord );
138
+ avroConsumer .addRecord (avroNullValueRecord );
135
139
});
136
140
protobufConsumer = new MockConsumer <>(OffsetResetStrategy .EARLIEST );
137
- ConsumerRecord <String , DynamicMessage > protobufRecord = createProtobufConsumerRecord ("protobuftest" , 0 , "k1" , createDynamicRecord ());
141
+ ConsumerRecord <String , DynamicMessage > protobufRecord = createProtobufConsumerRecord ("protobuftest" , 0 , 0 , "k1" , createDynamicRecord ());
142
+ ConsumerRecord <String , DynamicMessage > protobufNullValueRecord = createProtobufConsumerRecord ("protobuftest" , 0 , 1 , "k2" , null );
138
143
protobufConsumer .schedulePollTask (() -> {
139
144
protobufConsumer .addRecord (protobufRecord );
145
+ protobufConsumer .addRecord (protobufNullValueRecord );
140
146
});
141
147
spillConfig = SpillConfig .newBuilder ()
142
148
.withEncryptionKey (encryptionKey )
@@ -173,7 +179,7 @@ public void testForConsumeDataFromTopic() throws Exception {
173
179
offsets .put (new TopicPartition ("myTopic" , 0 ), 1L );
174
180
consumer .updateEndOffsets (offsets );
175
181
176
- SplitParameters splitParameters = new SplitParameters ("myTopic" , 0 , 0 , 1 );
182
+ SplitParameters splitParameters = new SplitParameters ("myTopic" , 0 , 0 , 2 );
177
183
Schema schema = createSchema (createCsvTopicSchema ());
178
184
179
185
mockedKafkaUtils .when (() -> KafkaUtils .getKafkaConsumer (schema , com .google .common .collect .ImmutableMap .of ())).thenReturn (consumer );
@@ -351,16 +357,16 @@ private ReadRecordsRequest createReadRecordsRequest(Schema schema) {
351
357
0 );
352
358
}
353
359
354
- private ConsumerRecord <String , TopicResultSet > createConsumerRecord (String topic , int partition , String key , TopicResultSet data ) throws Exception {
355
- return new ConsumerRecord <>(topic , partition , 0 , key , data );
360
+ private ConsumerRecord <String , TopicResultSet > createConsumerRecord (String topic , int partition , long offset , String key , TopicResultSet data ) throws Exception {
361
+ return new ConsumerRecord <>(topic , partition , offset , key , data );
356
362
}
357
363
358
- private ConsumerRecord <String , GenericRecord > createAvroConsumerRecord (String topic , int partition , String key , GenericRecord data ) throws Exception {
359
- return new ConsumerRecord <>(topic , partition , 0 , key , data );
364
+ private ConsumerRecord <String , GenericRecord > createAvroConsumerRecord (String topic , int partition , long offset , String key , GenericRecord data ) throws Exception {
365
+ return new ConsumerRecord <>(topic , partition , offset , key , data );
360
366
}
361
367
362
- private ConsumerRecord <String , DynamicMessage > createProtobufConsumerRecord (String topic , int partition , String key , DynamicMessage data ) throws Exception {
363
- return new ConsumerRecord <>(topic , partition , 0 , key , data );
368
+ private ConsumerRecord <String , DynamicMessage > createProtobufConsumerRecord (String topic , int partition , long offset , String key , DynamicMessage data ) throws Exception {
369
+ return new ConsumerRecord <>(topic , partition , offset , key , data );
364
370
}
365
371
366
372
private TopicResultSet createTopicResultSet (String topic ) {
0 commit comments