55use Jobcloud \Kafka \SchemaRegistryClient \Exception \ImportException ;
66use Jobcloud \Kafka \SchemaRegistryClient \Exception \SchemaNotFoundException ;
77use Jobcloud \Kafka \SchemaRegistryClient \Exception \SubjectNotFoundException ;
8+ use Jobcloud \Kafka \SchemaRegistryClient \Exception \VersionNotFoundException ;
89use Jobcloud \Kafka \SchemaRegistryClient \HttpClient ;
910use Jobcloud \Kafka \SchemaRegistryClient \HttpClientInterface ;
1011use Jobcloud \Kafka \SchemaRegistryClient \KafkaSchemaRegistryApiClient ;
@@ -208,7 +209,7 @@ public function testCheckSchemaCompatibilityForVersionFalse(): void
208209 self ::assertFalse ($ result );
209210 }
210211
211- public function testCheckSchemaCompatibilityForVersionNotFound (): void
212+ public function testCheckSchemaCompatibilityForSubjectNotFound (): void
212213 {
213214 $ httpClientMock = $ this ->getHttpClientMock ();
214215
@@ -231,6 +232,56 @@ public function testCheckSchemaCompatibilityForVersionNotFound(): void
231232 self ::assertTrue ($ result );
232233 }
233234
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+
234285 public function testGetSubjectCompatibilityLevel (): void
235286 {
236287 $ httpClientMock = $ this ->getHttpClientMock ();
0 commit comments