@@ -182,43 +182,47 @@ public void testJoinGroupRequestVersions() throws Exception {
182182 testAllMessageRoundTripsFromVersion ((short ) 5 , newRequest .get ().setGroupInstanceId ("instanceId" ));
183183 }
184184
185- @ Test
186- public void testListOffsetsRequestVersions () throws Exception {
187- List <ListOffsetsTopic > v = Collections .singletonList (new ListOffsetsTopic ()
188- .setName ("topic" )
189- .setPartitions (Collections .singletonList (new ListOffsetsPartition ()
190- .setPartitionIndex (0 )
191- .setTimestamp (123L ))));
192- Supplier <ListOffsetsRequestData > newRequest = () -> new ListOffsetsRequestData ()
193- .setTopics (v )
194- .setReplicaId (0 );
195- testAllMessageRoundTrips (newRequest .get ());
196- testAllMessageRoundTripsFromVersion ((short ) 2 , newRequest .get ().setIsolationLevel (IsolationLevel .READ_COMMITTED .id ()));
185+ @ ParameterizedTest
186+ @ ApiKeyVersionsSource (apiKey = ApiKeys .LIST_OFFSETS )
187+ public void testListOffsetsRequestVersions (short version ) throws Exception {
188+ ListOffsetsRequestData request = new ListOffsetsRequestData ()
189+ .setReplicaId (0 )
190+ .setIsolationLevel (version >= 2 ? IsolationLevel .READ_COMMITTED .id () : 0 )
191+ .setTopics (singletonList (
192+ new ListOffsetsTopic ()
193+ .setTopicId (version >= 12 ? Uuid .randomUuid () : Uuid .ZERO_UUID )
194+ .setName (version < 12 ? "topic" : "" )
195+ .setPartitions (singletonList (
196+ new ListOffsetsPartition ()
197+ .setPartitionIndex (0 )
198+ .setCurrentLeaderEpoch (version >= 4 ? 10 : -1 )
199+ .setTimestamp (123L )
200+ ))
201+ ));
202+
203+ testMessageRoundTrip (version , request , request );
197204 }
198205
199- @ Test
200- public void testListOffsetsResponseVersions () throws Exception {
201- ListOffsetsPartitionResponse partition = new ListOffsetsPartitionResponse ()
202- .setErrorCode (Errors .NONE .code ())
203- .setPartitionIndex (0 );
204- List <ListOffsetsTopicResponse > topics = Collections .singletonList (new ListOffsetsTopicResponse ()
205- .setName ("topic" )
206- .setPartitions (Collections .singletonList (partition )));
207- Supplier <ListOffsetsResponseData > response = () -> new ListOffsetsResponseData ()
208- .setTopics (topics );
209- for (short version = ApiKeys .LIST_OFFSETS .oldestVersion (); version <= ApiKeys .LIST_OFFSETS .latestVersion (); ++version ) {
210- ListOffsetsResponseData responseData = response .get ();
211- responseData .topics ().get (0 ).partitions ().get (0 )
212- .setOffset (456L )
213- .setTimestamp (123L );
214- if (version > 1 ) {
215- responseData .setThrottleTimeMs (1000 );
216- }
217- if (version > 3 ) {
218- partition .setLeaderEpoch (1 );
219- }
220- testEquivalentMessageRoundTrip (version , responseData );
221- }
206+ @ ParameterizedTest
207+ @ ApiKeyVersionsSource (apiKey = ApiKeys .LIST_OFFSETS )
208+ public void testListOffsetsResponseVersions (short version ) throws Exception {
209+ ListOffsetsResponseData response = new ListOffsetsResponseData ()
210+ .setThrottleTimeMs (version >= 2 ? 1000 : 0 )
211+ .setTopics (singletonList (
212+ new ListOffsetsTopicResponse ()
213+ .setTopicId (version >= 12 ? Uuid .randomUuid () : Uuid .ZERO_UUID )
214+ .setName (version < 12 ? "topic" : "" )
215+ .setPartitions (singletonList (
216+ new ListOffsetsPartitionResponse ()
217+ .setPartitionIndex (0 )
218+ .setErrorCode (Errors .NONE .code ())
219+ .setTimestamp (123L )
220+ .setOffset (456L )
221+ .setLeaderEpoch (version >= 4 ? 1 : -1 )
222+ ))
223+ ));
224+
225+ testMessageRoundTrip (version , response , response );
222226 }
223227
224228 @ Test
0 commit comments