6
6
use Jobcloud \Kafka \SchemaRegistryClient \Exception \SubjectNotFoundException ;
7
7
use Jobcloud \Kafka \SchemaRegistryClient \HttpClient ;
8
8
use Jobcloud \Kafka \SchemaRegistryClient \HttpClientInterface ;
9
- use Jobcloud \Kafka \SchemaRegistryClient \KafkaSchemaRegistryApiApiClient ;
9
+ use Jobcloud \Kafka \SchemaRegistryClient \KafkaSchemaRegistryApiClient ;
10
10
use Jobcloud \Kafka \SchemaRegistryClient \KafkaSchemaRegistryApiClientInterface ;
11
11
use PHPUnit \Framework \MockObject \MockObject ;
12
12
use PHPUnit \Framework \TestCase ;
@@ -35,7 +35,7 @@ public function testGetSubjects(): void
35
35
36
36
$ httpClientMock ->expects ($ this ->once ())->method ('call ' )->with ('GET ' , 'subjects ' );
37
37
38
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
38
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
39
39
$ api ->getSubjects ();
40
40
}
41
41
@@ -48,7 +48,7 @@ public function testGetAllSubjectVersions(): void
48
48
->method ('call ' )
49
49
->with ('GET ' , sprintf ('subjects/%s/versions ' , self ::TEST_SUBJECT_NAME ));
50
50
51
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
51
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
52
52
$ api ->getAllSubjectVersions (self ::TEST_SUBJECT_NAME );
53
53
}
54
54
@@ -62,7 +62,7 @@ public function testGetSchemaByVersion(): void
62
62
->with ('GET ' , sprintf ('subjects/%s/versions/%s ' , self ::TEST_SUBJECT_NAME , self ::TEST_VERSION ))
63
63
->willReturn (['schema ' => '{} ' ]);
64
64
65
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
65
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
66
66
$ result = $ api ->getSchemaByVersion (self ::TEST_SUBJECT_NAME , self ::TEST_VERSION );
67
67
68
68
$ this ->assertSame (['schema ' => '{} ' ], $ result );
@@ -78,7 +78,7 @@ public function testGetSchemaDefinitionByVersion(): void
78
78
->with ('GET ' , sprintf ('subjects/%s/versions/%s/schema ' , self ::TEST_SUBJECT_NAME , self ::TEST_VERSION ))
79
79
->willReturn (['a ' => 'b ' ]);
80
80
81
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
81
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
82
82
$ result = $ api ->getSchemaDefinitionByVersion (self ::TEST_SUBJECT_NAME , self ::TEST_VERSION );
83
83
84
84
$ this ->assertSame (['a ' => 'b ' ], $ result );
@@ -94,7 +94,7 @@ public function testDeleteSchemaVersion(): void
94
94
->with ('DELETE ' , sprintf ('subjects/%s/versions/%s ' , self ::TEST_SUBJECT_NAME , self ::TEST_VERSION ))
95
95
->willReturn (1 );
96
96
97
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
97
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
98
98
$ result = $ api ->deleteSchemaVersion (self ::TEST_SUBJECT_NAME , self ::TEST_VERSION );
99
99
100
100
$ this ->assertSame (1 , $ result );
@@ -110,7 +110,7 @@ public function testGetSchemaById(): void
110
110
->with ('GET ' , sprintf ('schemas/ids/%s ' , 1 ))
111
111
->willReturn (['schema ' => '{} ' ]);
112
112
113
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
113
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
114
114
$ api ->getSchemaById (1 );
115
115
}
116
116
@@ -124,7 +124,7 @@ public function testRegisterNewSchemaVersion(): void
124
124
->with ('POST ' , sprintf ('subjects/%s/versions ' , self ::TEST_SUBJECT_NAME ), ['schema ' => '[] ' ])
125
125
->willReturn ([]);
126
126
127
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
127
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
128
128
$ api ->registerNewSchemaVersion (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
129
129
}
130
130
@@ -142,7 +142,7 @@ public function testCheckSchemaCompatibilityForVersionTrue(): void
142
142
)
143
143
->willReturn (['is_compatible ' => true ]);
144
144
145
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
145
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
146
146
$ result = $ api ->checkSchemaCompatibilityForVersion (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA , self ::TEST_VERSION );
147
147
$ this ->assertTrue ($ result );
148
148
}
@@ -161,7 +161,7 @@ public function testCheckSchemaCompatibilityForVersionFalse(): void
161
161
)
162
162
->willReturn (['is_compatible ' => false ]);
163
163
164
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
164
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
165
165
$ result = $ api ->checkSchemaCompatibilityForVersion (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA , self ::TEST_VERSION );
166
166
$ this ->assertFalse ($ result );
167
167
}
@@ -180,7 +180,7 @@ public function testCheckSchemaCompatibilityForVersionNotFound(): void
180
180
)
181
181
->willThrowException (new SubjectNotFoundException ());
182
182
183
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
183
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
184
184
$ result = $ api ->checkSchemaCompatibilityForVersion (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA , self ::TEST_VERSION );
185
185
$ this ->assertTrue ($ result );
186
186
}
@@ -198,7 +198,7 @@ public function testGetSubjectCompatibilityLevel(): void
198
198
)
199
199
->willReturn (['compatibilityLevel ' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL ]);
200
200
201
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
201
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
202
202
$ result = $ api ->getSubjectCompatibilityLevel (self ::TEST_SUBJECT_NAME );
203
203
$ this ->assertSame (KafkaSchemaRegistryApiClientInterface::LEVEL_FULL , $ result );
204
204
}
@@ -218,7 +218,7 @@ public function testGetDefaultCompatibiltyLeveWhenGetSubjectCompatibilityLevelTh
218
218
->method ('call ' )
219
219
->willReturn (['compatibilityLevel ' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL ]);
220
220
221
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
221
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
222
222
$ result = $ api ->getSubjectCompatibilityLevel (self ::TEST_SUBJECT_NAME );
223
223
$ this ->assertSame (KafkaSchemaRegistryApiClientInterface::LEVEL_FULL , $ result );
224
224
}
@@ -236,7 +236,7 @@ public function testSetSubjectCompatibilityLevel(): void
236
236
['compatibility ' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL ]
237
237
);
238
238
239
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
239
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
240
240
$ result = $ api ->setSubjectCompatibilityLevel (
241
241
self ::TEST_SUBJECT_NAME ,
242
242
KafkaSchemaRegistryApiClientInterface::LEVEL_FULL
@@ -255,7 +255,7 @@ public function testGetDefaultCompatibilityLeve(): void
255
255
->with ('GET ' , sprintf ('config ' ))
256
256
->willReturn (['compatibilityLevel ' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL ]);
257
257
258
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
258
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
259
259
$ result = $ api ->getDefaultCompatibilityLevel ();
260
260
$ this ->assertSame (KafkaSchemaRegistryApiClientInterface::LEVEL_FULL , $ result );
261
261
}
@@ -269,7 +269,7 @@ public function testSetDefaultCompatibilityLeve(): void
269
269
->method ('call ' )
270
270
->with ('PUT ' , 'config ' , ['compatibility ' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL ]);
271
271
272
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
272
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
273
273
$ result = $ api ->setDefaultCompatibilityLevel ();
274
274
$ this ->assertTrue ($ result );
275
275
}
@@ -288,7 +288,7 @@ public function testGetVersionForSchema(): void
288
288
)
289
289
->willReturn (['version ' => self ::TEST_VERSION ]);
290
290
291
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
291
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
292
292
$ result = $ api ->getVersionForSchema (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
293
293
$ this ->assertSame ((string ) self ::TEST_VERSION , $ result );
294
294
}
@@ -307,7 +307,7 @@ public function testGetVersionForSchemaThrowsSubjectNotFoundExceptionResultsAsNu
307
307
)
308
308
->willThrowException (new SubjectNotFoundException ());
309
309
310
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
310
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
311
311
$ result = $ api ->getVersionForSchema (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
312
312
$ this ->assertNull ($ result );
313
313
}
@@ -326,7 +326,7 @@ public function testGetVersionForSchemaThrowsSchematNotFoundExceptionResultsAsNu
326
326
)
327
327
->willThrowException (new SchemaNotFoundException ());
328
328
329
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
329
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
330
330
$ result = $ api ->getVersionForSchema (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
331
331
$ this ->assertNull ($ result );
332
332
}
@@ -345,7 +345,7 @@ public function testSchemaExistsTrue(): void
345
345
)
346
346
->willReturn (['version ' => self ::TEST_VERSION ]);
347
347
348
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
348
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
349
349
$ result = $ api ->isSchemaAlreadyRegistered (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
350
350
$ this ->assertTrue ($ result );
351
351
}
@@ -364,7 +364,7 @@ public function testSchemaExistsFalse(): void
364
364
)
365
365
->willThrowException (new SubjectNotFoundException ());
366
366
367
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
367
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
368
368
$ result = $ api ->isSchemaAlreadyRegistered (self ::TEST_SUBJECT_NAME , self ::TEST_SCHEMA );
369
369
$ this ->assertFalse ($ result );
370
370
}
@@ -379,7 +379,7 @@ public function testDeleteSubject(): void
379
379
->with ('DELETE ' , sprintf ('subjects/%s ' , self ::TEST_SUBJECT_NAME ))
380
380
->willReturn ([1 ,2 ,3 ,4 ]);
381
381
382
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
382
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
383
383
$ result = $ api ->deleteSubject (self ::TEST_SUBJECT_NAME );
384
384
385
385
$ this ->assertSame ([1 ,2 ,3 ,4 ], $ result );
@@ -395,7 +395,7 @@ public function testGetLatestSubjectVersion(): void
395
395
->with ('GET ' , sprintf ('subjects/%s/versions ' , self ::TEST_SUBJECT_NAME ))
396
396
->willReturn ([1 ,2 ,3 ,4 ,5 ,6 ]);
397
397
398
- $ api = new KafkaSchemaRegistryApiApiClient ($ httpClientMock );
398
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
399
399
$ result = $ api ->getLatestSubjectVersion (self ::TEST_SUBJECT_NAME );
400
400
$ this ->assertSame ('6 ' , $ result );
401
401
}
0 commit comments