28
28
import org .apache .kafka .common .network .ListenerName ;
29
29
import org .apache .kafka .common .security .auth .SecurityProtocol ;
30
30
31
+ import org .apache .kafka .common .utils .MockTime ;
32
+ import org .apache .kafka .common .utils .Time ;
31
33
import org .junit .jupiter .api .BeforeEach ;
32
34
import org .junit .jupiter .api .Nested ;
33
35
import org .junit .jupiter .api .Test ;
@@ -62,16 +64,20 @@ class InklessTopicMetadataTransformerTest {
62
64
static final Uuid TOPIC_CLASSIC_ID = new Uuid (456 , 456 );
63
65
static final ListenerName LISTENER_NAME = ListenerName .forSecurityProtocol (SecurityProtocol .PLAINTEXT );
64
66
67
+ Time time = new MockTime ();
65
68
@ Mock
66
69
MetadataView metadataView ;
67
70
68
71
@ Test
69
72
void nulls () {
70
- assertThatThrownBy (() -> new InklessTopicMetadataTransformer (null ))
73
+ assertThatThrownBy (() -> new InklessTopicMetadataTransformer (null , metadataView ))
74
+ .isInstanceOf (NullPointerException .class )
75
+ .hasMessage ("time cannot be null" );
76
+ assertThatThrownBy (() -> new InklessTopicMetadataTransformer (time , null ))
71
77
.isInstanceOf (NullPointerException .class )
72
78
.hasMessage ("metadataView cannot be null" );
73
79
74
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
80
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
75
81
assertThatThrownBy (() -> transformer .transformClusterMetadata (LISTENER_NAME , "x" , null ))
76
82
.isInstanceOf (NullPointerException .class )
77
83
.hasMessage ("topicMetadata cannot be null" );
@@ -94,7 +100,7 @@ void setup() {
94
100
@ NullSource
95
101
@ ValueSource (strings = {"inkless_az=az1" , "x=y" , "" })
96
102
void clusterMetadata (final String clientId ) {
97
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
103
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
98
104
99
105
final List <MetadataResponseTopic > topicMetadata = List .of ();
100
106
transformer .transformClusterMetadata (LISTENER_NAME , clientId , topicMetadata );
@@ -105,7 +111,7 @@ void clusterMetadata(final String clientId) {
105
111
@ NullSource
106
112
@ ValueSource (strings = {"inkless_az=az1" , "x=y" , "" })
107
113
void describeTopicResponse (final String clientId ) {
108
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
114
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
109
115
110
116
final DescribeTopicPartitionsResponseData describeResponse = new DescribeTopicPartitionsResponseData ();
111
117
transformer .transformDescribeTopicResponse (LISTENER_NAME , clientId , describeResponse );
@@ -186,7 +192,7 @@ void clusterMetadata(final String clientAZ, final int expectedLeaderId1, final i
186
192
inklessTopicMetadata .get (),
187
193
classicTopicMetadata .get ()
188
194
);
189
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
195
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
190
196
191
197
transformer .transformClusterMetadata (LISTENER_NAME , "inkless_az=" + clientAZ , topicMetadata );
192
198
@@ -279,7 +285,7 @@ void describeTopicResponse(final String clientAZ, final int expectedLeaderId1, f
279
285
inklessTopicMetadata .get (),
280
286
classicTopicMetadata .get ()
281
287
).iterator ()));
282
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
288
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
283
289
284
290
transformer .transformDescribeTopicResponse (LISTENER_NAME , "inkless_az=" + clientAZ , describeResponse );
285
291
@@ -333,7 +339,7 @@ void clusterMetadata() {
333
339
));
334
340
335
341
final List <MetadataResponseTopic > topicMetadata = List .of (inklessTopicMetadata .get ());
336
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
342
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
337
343
338
344
transformer .transformClusterMetadata (LISTENER_NAME , "inkless_az=az0" , topicMetadata );
339
345
final var expectedInklessTopicMetadata = inklessTopicMetadata .get ();
@@ -368,7 +374,7 @@ void describeTopicResponse() {
368
374
))
369
375
).iterator ()));
370
376
371
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
377
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
372
378
373
379
final DescribeTopicPartitionsResponseData describeResponse = describeResponseSupplier .get ();
374
380
transformer .transformDescribeTopicResponse (LISTENER_NAME , "inkless_az=az0" , describeResponse );
@@ -413,7 +419,7 @@ void clusterMetadata() {
413
419
));
414
420
415
421
final List <MetadataResponseTopic > topicMetadata = List .of (inklessTopicMetadata .get ());
416
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
422
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
417
423
418
424
transformer .transformClusterMetadata (LISTENER_NAME , null , topicMetadata );
419
425
final var expectedInklessTopicMetadata = inklessTopicMetadata .get ();
@@ -448,7 +454,7 @@ void describeTopicResponse() {
448
454
))
449
455
).iterator ()));
450
456
451
- final var transformer = new InklessTopicMetadataTransformer (metadataView );
457
+ final var transformer = new InklessTopicMetadataTransformer (time , metadataView );
452
458
final DescribeTopicPartitionsResponseData describeResponse = describeResponseSupplier .get ();
453
459
454
460
transformer .transformDescribeTopicResponse (LISTENER_NAME , null , describeResponse );
0 commit comments