@@ -3898,6 +3898,9 @@ public void testInvokeRecordInterceptorAllSkipped(AckMode ackMode, boolean early
3898
3898
containerProps .setMessageListener ((MessageListener <?, ?>) msg -> {
3899
3899
});
3900
3900
containerProps .setClientId ("clientId" );
3901
+ if (early ) {
3902
+ containerProps .setTransactionManager (mock (PlatformTransactionManager .class ));
3903
+ }
3901
3904
3902
3905
RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3903
3906
@@ -3922,17 +3925,27 @@ public ConsumerRecord<Integer, String> intercept(ConsumerRecord<Integer, String>
3922
3925
inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
3923
3926
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3924
3927
inOrder .verify (recordInterceptor ).intercept (eq (firstRecord ), eq (consumer ));
3925
- if (ackMode . equals ( AckMode .RECORD )) {
3928
+ if (AckMode .RECORD . equals ( ackMode )) {
3926
3929
inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (1L ))),
3927
3930
any (Duration .class ));
3928
3931
}
3929
3932
else {
3930
3933
verify (consumer , never ()).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (1L ))),
3931
3934
any (Duration .class ));
3932
3935
}
3936
+ inOrder .verify (recordInterceptor ).success (eq (firstRecord ), eq (consumer ));
3937
+ inOrder .verify (recordInterceptor ).afterRecord (eq (firstRecord ), eq (consumer ));
3933
3938
inOrder .verify (recordInterceptor ).intercept (eq (secondRecord ), eq (consumer ));
3934
- inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3935
- any (Duration .class ));
3939
+ if (AckMode .RECORD .equals (ackMode )) {
3940
+ inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3941
+ any (Duration .class ));
3942
+ }
3943
+ inOrder .verify (recordInterceptor ).success (eq (secondRecord ), eq (consumer ));
3944
+ inOrder .verify (recordInterceptor ).afterRecord (eq (secondRecord ), eq (consumer ));
3945
+ if (AckMode .BATCH .equals (ackMode )) {
3946
+ inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3947
+ any (Duration .class ));
3948
+ }
3936
3949
container .stop ();
3937
3950
}
3938
3951
@@ -3968,7 +3981,7 @@ public void testInvokeBatchInterceptorAllSkipped(boolean early) throws Exception
3968
3981
containerProps .setMessageListener ((BatchMessageListener <?, ?>) msgs -> {
3969
3982
});
3970
3983
containerProps .setClientId ("clientId" );
3971
- if (! early ) {
3984
+ if (early ) {
3972
3985
containerProps .setTransactionManager (mock (PlatformTransactionManager .class ));
3973
3986
}
3974
3987
@@ -3995,6 +4008,7 @@ public ConsumerRecords<Integer, String> intercept(ConsumerRecords<Integer, Strin
3995
4008
inOrder .verify (interceptor ).setupThreadState (eq (consumer ));
3996
4009
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3997
4010
inOrder .verify (interceptor ).intercept (any (), eq (consumer ));
4011
+ inOrder .verify (interceptor ).success (any (), eq (consumer ));
3998
4012
inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3999
4013
any (Duration .class ));
4000
4014
container .stop ();
0 commit comments