Skip to content

Commit eb3878d

Browse files
authored
Double api in naming of class (#2)
1 parent 6ca4cc8 commit eb3878d

4 files changed

+28
-28
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ composer require jobcloud/php-kafka-schema-registry-client
3737
use Buzz\Client\Curl;
3838
use Jobcloud\Kafka\SchemaRegistryClient\ErrorHandler;
3939
use Jobcloud\Kafka\SchemaRegistryClient\HttpClient;
40-
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiApiClient;
40+
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClient;
4141
use Nyholm\Psr7\Factory\Psr17Factory;
4242

4343
require 'vendor/autoload.php';
@@ -57,7 +57,7 @@ $registryClient = new HttpClient(
5757
);
5858

5959
$schema = '{"type":"record","name":"something","namespace":"whatever.you.want","fields":[{"name":"id","type":"string"}]}';
60-
$registryClientApi = new KafkaSchemaRegistryApiApiClient($registryClient);
60+
$registryClientApi = new KafkaSchemaRegistryApiClient($registryClient);
6161
$subjectName = 'some.subject.name';
6262

6363
$results = $registryClientApi->getVersionForSchema($subjectName, $schema);

src/KafkaSchemaRegistryApiApiClient.php src/KafkaSchemaRegistryApiClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SchemaNotFoundException;
88
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SubjectNotFoundException;
99

10-
class KafkaSchemaRegistryApiApiClient implements KafkaSchemaRegistryApiClientInterface
10+
class KafkaSchemaRegistryApiClient implements KafkaSchemaRegistryApiClientInterface
1111
{
1212
/**
1313
* @var HttpClientInterface

src/ServiceProvider/KafkaSchemaRegistryApiClientProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Buzz\Client\Curl;
66
use Jobcloud\Kafka\SchemaRegistryClient\ErrorHandler;
77
use Jobcloud\Kafka\SchemaRegistryClient\HttpClient;
8-
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiApiClient;
8+
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClient;
99
use LogicException;
1010
use Nyholm\Psr7\Factory\Psr17Factory;
1111
use Pimple\Container;
@@ -77,7 +77,7 @@ public function register(Container $container)
7777
/** @var HttpClient $client */
7878
$client = $container[self::HTTP_CLIENT];
7979

80-
return new KafkaSchemaRegistryApiApiClient($client);
80+
return new KafkaSchemaRegistryApiClient($client);
8181
};
8282
}
8383
}

tests/KafkaSchemaRegistryApiApiClientTest.php

+23-23
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SubjectNotFoundException;
77
use Jobcloud\Kafka\SchemaRegistryClient\HttpClient;
88
use Jobcloud\Kafka\SchemaRegistryClient\HttpClientInterface;
9-
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiApiClient;
9+
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClient;
1010
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClientInterface;
1111
use PHPUnit\Framework\MockObject\MockObject;
1212
use PHPUnit\Framework\TestCase;
@@ -35,7 +35,7 @@ public function testGetSubjects(): void
3535

3636
$httpClientMock->expects($this->once())->method('call')->with('GET', 'subjects');
3737

38-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
38+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
3939
$api->getSubjects();
4040
}
4141

@@ -48,7 +48,7 @@ public function testGetAllSubjectVersions(): void
4848
->method('call')
4949
->with('GET', sprintf('subjects/%s/versions', self::TEST_SUBJECT_NAME));
5050

51-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
51+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
5252
$api->getAllSubjectVersions(self::TEST_SUBJECT_NAME);
5353
}
5454

@@ -62,7 +62,7 @@ public function testGetSchemaByVersion(): void
6262
->with('GET', sprintf('subjects/%s/versions/%s', self::TEST_SUBJECT_NAME, self::TEST_VERSION))
6363
->willReturn(['schema' => '{}']);
6464

65-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
65+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
6666
$result = $api->getSchemaByVersion(self::TEST_SUBJECT_NAME, self::TEST_VERSION);
6767

6868
$this->assertSame(['schema' => '{}'], $result);
@@ -78,7 +78,7 @@ public function testGetSchemaDefinitionByVersion(): void
7878
->with('GET', sprintf('subjects/%s/versions/%s/schema', self::TEST_SUBJECT_NAME, self::TEST_VERSION))
7979
->willReturn(['a' => 'b']);
8080

81-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
81+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
8282
$result = $api->getSchemaDefinitionByVersion(self::TEST_SUBJECT_NAME, self::TEST_VERSION);
8383

8484
$this->assertSame(['a' => 'b'], $result);
@@ -94,7 +94,7 @@ public function testDeleteSchemaVersion(): void
9494
->with('DELETE', sprintf('subjects/%s/versions/%s', self::TEST_SUBJECT_NAME, self::TEST_VERSION))
9595
->willReturn(1);
9696

97-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
97+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
9898
$result = $api->deleteSchemaVersion(self::TEST_SUBJECT_NAME, self::TEST_VERSION);
9999

100100
$this->assertSame(1, $result);
@@ -110,7 +110,7 @@ public function testGetSchemaById(): void
110110
->with('GET', sprintf('schemas/ids/%s', 1))
111111
->willReturn(['schema' => '{}']);
112112

113-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
113+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
114114
$api->getSchemaById(1);
115115
}
116116

@@ -124,7 +124,7 @@ public function testRegisterNewSchemaVersion(): void
124124
->with('POST', sprintf('subjects/%s/versions', self::TEST_SUBJECT_NAME), ['schema' => '[]'])
125125
->willReturn([]);
126126

127-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
127+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
128128
$api->registerNewSchemaVersion(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
129129
}
130130

@@ -142,7 +142,7 @@ public function testCheckSchemaCompatibilityForVersionTrue(): void
142142
)
143143
->willReturn(['is_compatible' => true]);
144144

145-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
145+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
146146
$result = $api->checkSchemaCompatibilityForVersion(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA, self::TEST_VERSION);
147147
$this->assertTrue($result);
148148
}
@@ -161,7 +161,7 @@ public function testCheckSchemaCompatibilityForVersionFalse(): void
161161
)
162162
->willReturn(['is_compatible' => false]);
163163

164-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
164+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
165165
$result = $api->checkSchemaCompatibilityForVersion(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA, self::TEST_VERSION);
166166
$this->assertFalse($result);
167167
}
@@ -180,7 +180,7 @@ public function testCheckSchemaCompatibilityForVersionNotFound(): void
180180
)
181181
->willThrowException(new SubjectNotFoundException());
182182

183-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
183+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
184184
$result = $api->checkSchemaCompatibilityForVersion(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA, self::TEST_VERSION);
185185
$this->assertTrue($result);
186186
}
@@ -198,7 +198,7 @@ public function testGetSubjectCompatibilityLevel(): void
198198
)
199199
->willReturn(['compatibilityLevel' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL]);
200200

201-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
201+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
202202
$result = $api->getSubjectCompatibilityLevel(self::TEST_SUBJECT_NAME);
203203
$this->assertSame(KafkaSchemaRegistryApiClientInterface::LEVEL_FULL, $result);
204204
}
@@ -218,7 +218,7 @@ public function testGetDefaultCompatibiltyLeveWhenGetSubjectCompatibilityLevelTh
218218
->method('call')
219219
->willReturn(['compatibilityLevel' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL]);
220220

221-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
221+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
222222
$result = $api->getSubjectCompatibilityLevel(self::TEST_SUBJECT_NAME);
223223
$this->assertSame(KafkaSchemaRegistryApiClientInterface::LEVEL_FULL, $result);
224224
}
@@ -236,7 +236,7 @@ public function testSetSubjectCompatibilityLevel(): void
236236
['compatibility' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL]
237237
);
238238

239-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
239+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
240240
$result = $api->setSubjectCompatibilityLevel(
241241
self::TEST_SUBJECT_NAME,
242242
KafkaSchemaRegistryApiClientInterface::LEVEL_FULL
@@ -255,7 +255,7 @@ public function testGetDefaultCompatibilityLeve(): void
255255
->with('GET', sprintf('config'))
256256
->willReturn(['compatibilityLevel' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL]);
257257

258-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
258+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
259259
$result = $api->getDefaultCompatibilityLevel();
260260
$this->assertSame(KafkaSchemaRegistryApiClientInterface::LEVEL_FULL, $result);
261261
}
@@ -269,7 +269,7 @@ public function testSetDefaultCompatibilityLeve(): void
269269
->method('call')
270270
->with('PUT', 'config', ['compatibility' => KafkaSchemaRegistryApiClientInterface::LEVEL_FULL]);
271271

272-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
272+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
273273
$result = $api->setDefaultCompatibilityLevel();
274274
$this->assertTrue($result);
275275
}
@@ -288,7 +288,7 @@ public function testGetVersionForSchema(): void
288288
)
289289
->willReturn(['version' => self::TEST_VERSION]);
290290

291-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
291+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
292292
$result = $api->getVersionForSchema(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
293293
$this->assertSame((string) self::TEST_VERSION, $result);
294294
}
@@ -307,7 +307,7 @@ public function testGetVersionForSchemaThrowsSubjectNotFoundExceptionResultsAsNu
307307
)
308308
->willThrowException(new SubjectNotFoundException());
309309

310-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
310+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
311311
$result = $api->getVersionForSchema(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
312312
$this->assertNull($result);
313313
}
@@ -326,7 +326,7 @@ public function testGetVersionForSchemaThrowsSchematNotFoundExceptionResultsAsNu
326326
)
327327
->willThrowException(new SchemaNotFoundException());
328328

329-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
329+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
330330
$result = $api->getVersionForSchema(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
331331
$this->assertNull($result);
332332
}
@@ -345,7 +345,7 @@ public function testSchemaExistsTrue(): void
345345
)
346346
->willReturn(['version' => self::TEST_VERSION]);
347347

348-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
348+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
349349
$result = $api->isSchemaAlreadyRegistered(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
350350
$this->assertTrue($result);
351351
}
@@ -364,7 +364,7 @@ public function testSchemaExistsFalse(): void
364364
)
365365
->willThrowException(new SubjectNotFoundException());
366366

367-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
367+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
368368
$result = $api->isSchemaAlreadyRegistered(self::TEST_SUBJECT_NAME, self::TEST_SCHEMA);
369369
$this->assertFalse($result);
370370
}
@@ -379,7 +379,7 @@ public function testDeleteSubject(): void
379379
->with('DELETE', sprintf('subjects/%s', self::TEST_SUBJECT_NAME))
380380
->willReturn([1,2,3,4]);
381381

382-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
382+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
383383
$result = $api->deleteSubject(self::TEST_SUBJECT_NAME);
384384

385385
$this->assertSame([1,2,3,4], $result);
@@ -395,7 +395,7 @@ public function testGetLatestSubjectVersion(): void
395395
->with('GET', sprintf('subjects/%s/versions', self::TEST_SUBJECT_NAME))
396396
->willReturn([1,2,3,4,5,6]);
397397

398-
$api = new KafkaSchemaRegistryApiApiClient($httpClientMock);
398+
$api = new KafkaSchemaRegistryApiClient($httpClientMock);
399399
$result = $api->getLatestSubjectVersion(self::TEST_SUBJECT_NAME);
400400
$this->assertSame('6', $result);
401401
}

0 commit comments

Comments
 (0)