@@ -3901,6 +3901,9 @@ public void testInvokeRecordInterceptorAllSkipped(AckMode ackMode, boolean early
3901
3901
containerProps .setMessageListener ((MessageListener ) msg -> {
3902
3902
});
3903
3903
containerProps .setClientId ("clientId" );
3904
+ if (early ) {
3905
+ containerProps .setTransactionManager (mock (PlatformTransactionManager .class ));
3906
+ }
3904
3907
3905
3908
RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3906
3909
@@ -3925,17 +3928,27 @@ public ConsumerRecord<Integer, String> intercept(ConsumerRecord<Integer, String>
3925
3928
inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
3926
3929
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3927
3930
inOrder .verify (recordInterceptor ).intercept (eq (firstRecord ), eq (consumer ));
3928
- if (ackMode . equals ( AckMode .RECORD )) {
3931
+ if (AckMode .RECORD . equals ( ackMode )) {
3929
3932
inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (1L ))),
3930
3933
any (Duration .class ));
3931
3934
}
3932
3935
else {
3933
3936
verify (consumer , never ()).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (1L ))),
3934
3937
any (Duration .class ));
3935
3938
}
3939
+ inOrder .verify (recordInterceptor ).success (eq (firstRecord ), eq (consumer ));
3940
+ inOrder .verify (recordInterceptor ).afterRecord (eq (firstRecord ), eq (consumer ));
3936
3941
inOrder .verify (recordInterceptor ).intercept (eq (secondRecord ), eq (consumer ));
3937
- inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3938
- any (Duration .class ));
3942
+ if (AckMode .RECORD .equals (ackMode )) {
3943
+ inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3944
+ any (Duration .class ));
3945
+ }
3946
+ inOrder .verify (recordInterceptor ).success (eq (secondRecord ), eq (consumer ));
3947
+ inOrder .verify (recordInterceptor ).afterRecord (eq (secondRecord ), eq (consumer ));
3948
+ if (AckMode .BATCH .equals (ackMode )) {
3949
+ inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
3950
+ any (Duration .class ));
3951
+ }
3939
3952
container .stop ();
3940
3953
}
3941
3954
@@ -3971,7 +3984,7 @@ public void testInvokeBatchInterceptorAllSkipped(boolean early) throws Exception
3971
3984
containerProps .setMessageListener ((BatchMessageListener ) msgs -> {
3972
3985
});
3973
3986
containerProps .setClientId ("clientId" );
3974
- if (! early ) {
3987
+ if (early ) {
3975
3988
containerProps .setTransactionManager (mock (PlatformTransactionManager .class ));
3976
3989
}
3977
3990
@@ -3998,6 +4011,7 @@ public ConsumerRecords<Integer, String> intercept(ConsumerRecords<Integer, Strin
3998
4011
inOrder .verify (interceptor ).setupThreadState (eq (consumer ));
3999
4012
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
4000
4013
inOrder .verify (interceptor ).intercept (any (), eq (consumer ));
4014
+ inOrder .verify (interceptor ).success (any (), eq (consumer ));
4001
4015
inOrder .verify (consumer ).commitSync (eq (Map .of (new TopicPartition ("foo" , 0 ), new OffsetAndMetadata (2L ))),
4002
4016
any (Duration .class ));
4003
4017
container .stop ();
0 commit comments