5
5
use Jobcloud \Kafka \SchemaRegistryClient \Exception \ImportException ;
6
6
use Jobcloud \Kafka \SchemaRegistryClient \Exception \SchemaNotFoundException ;
7
7
use Jobcloud \Kafka \SchemaRegistryClient \Exception \SubjectNotFoundException ;
8
+ use Jobcloud \Kafka \SchemaRegistryClient \Exception \VersionNotFoundException ;
8
9
use Jobcloud \Kafka \SchemaRegistryClient \HttpClient ;
9
10
use Jobcloud \Kafka \SchemaRegistryClient \HttpClientInterface ;
10
11
use Jobcloud \Kafka \SchemaRegistryClient \KafkaSchemaRegistryApiClient ;
@@ -208,7 +209,7 @@ public function testCheckSchemaCompatibilityForVersionFalse(): void
208
209
self ::assertFalse ($ result );
209
210
}
210
211
211
- public function testCheckSchemaCompatibilityForVersionNotFound (): void
212
+ public function testCheckSchemaCompatibilityForSubjectNotFound (): void
212
213
{
213
214
$ httpClientMock = $ this ->getHttpClientMock ();
214
215
@@ -231,6 +232,56 @@ public function testCheckSchemaCompatibilityForVersionNotFound(): void
231
232
self ::assertTrue ($ result );
232
233
}
233
234
235
+ public function testCheckSchemaCompatibilityForVersionNotFound (): void
236
+ {
237
+ self ::expectException (VersionNotFoundException::class);
238
+ $ httpClientMock = $ this ->getHttpClientMock ();
239
+
240
+ $ httpClientMock
241
+ ->expects (self ::once ())
242
+ ->method ('call ' )
243
+ ->with (
244
+ 'POST ' ,
245
+ sprintf ('compatibility/subjects/%s/versions/%s ' , self ::TEST_SUBJECT_NAME , self ::TEST_VERSION ),
246
+ ['schema ' => '[] ' ]
247
+ )
248
+ ->willThrowException (new VersionNotFoundException ());
249
+
250
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
251
+ $ result = $ api ->checkSchemaCompatibilityForVersion (
252
+ self ::TEST_SUBJECT_NAME ,
253
+ self ::TEST_SCHEMA ,
254
+ self ::TEST_VERSION
255
+ );
256
+ }
257
+
258
+ public function testCheckSchemaCompatibilityForVersionNotFoundLatest (): void
259
+ {
260
+ $ httpClientMock = $ this ->getHttpClientMock ();
261
+
262
+ $ httpClientMock
263
+ ->expects (self ::once ())
264
+ ->method ('call ' )
265
+ ->with (
266
+ 'POST ' ,
267
+ sprintf (
268
+ 'compatibility/subjects/%s/versions/%s ' ,
269
+ self ::TEST_SUBJECT_NAME ,
270
+ KafkaSchemaRegistryApiClient::VERSION_LATEST
271
+ ),
272
+ ['schema ' => '[] ' ]
273
+ )
274
+ ->willThrowException (new VersionNotFoundException ());
275
+
276
+ $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
277
+ $ result = $ api ->checkSchemaCompatibilityForVersion (
278
+ self ::TEST_SUBJECT_NAME ,
279
+ self ::TEST_SCHEMA ,
280
+ KafkaSchemaRegistryApiClient::VERSION_LATEST
281
+ );
282
+ self ::assertTrue ($ result );
283
+ }
284
+
234
285
public function testGetSubjectCompatibilityLevel (): void
235
286
{
236
287
$ httpClientMock = $ this ->getHttpClientMock ();
0 commit comments