-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split integration test for delete schema + fix style/indent
- Loading branch information
1 parent
b1e5904
commit c0ff8cd
Showing
4 changed files
with
142 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -766,12 +766,110 @@ void shouldRegisterSameSchemaTwice() { | |
assertNotNull(schemaAfterPostOnRegistry.id()); | ||
assertEquals(2, schemaAfterPostOnRegistry.version()); | ||
assertEquals("ns1-subject3-value", schemaAfterPostOnRegistry.subject()); | ||
} | ||
|
||
@Test | ||
void shouldDeleteSchema() { | ||
Schema schemaV1 = Schema.builder() | ||
.metadata(Metadata.builder() | ||
.name("ns1-subject4-value") | ||
.build()) | ||
.spec(Schema.SchemaSpec.builder() | ||
.schema( | ||
"{\"namespace\":\"com.michelin.kafka.producer.showcase.avro\",\"type\":\"record\"," | ||
+ "\"name\":\"PersonAvro\",\"fields\":[" | ||
+ "{\"name\":\"field1\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field2\",\"type\":[\"null\",\"string\"]}]}") | ||
.build()) | ||
.build(); | ||
|
||
// Register V1 schema | ||
var createV1Response = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.POST, "/api/namespaces/ns1/schemas") | ||
.bearerAuth(token) | ||
.body(schemaV1), Schema.class); | ||
|
||
assertEquals("created", createV1Response.header("X-Ns4kafka-Result")); | ||
|
||
Schema schemaV2 = Schema.builder() | ||
.metadata(Metadata.builder() | ||
.name("ns1-subject4-value") | ||
.build()) | ||
.spec(Schema.SchemaSpec.builder() | ||
.schema( | ||
"{\"namespace\":\"com.michelin.kafka.producer.showcase.avro\",\"type\":\"record\"," | ||
+ "\"name\":\"PersonAvro\",\"fields\":[" | ||
+ "{\"name\":\"field1\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field2\",\"type\":[\"null\",\"string\"]}]}") | ||
.build()) | ||
.build(); | ||
|
||
// Register V2 schema | ||
var createV2Response = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.POST, "/api/namespaces/ns1/schemas") | ||
.bearerAuth(token) | ||
.body(schemaV2), Schema.class); | ||
|
||
assertEquals("created", createV2Response.header("X-Ns4kafka-Result")); | ||
Check failure on line 817 in src/test/java/com/michelin/ns4kafka/integration/SchemaIntegrationTest.java GitHub Actions / JUnit Test ReportSchemaIntegrationTest.shouldDeleteSchema()
Raw output
|
||
|
||
Schema schemaV3 = Schema.builder() | ||
.metadata(Metadata.builder() | ||
.name("ns1-subject4-value") | ||
.build()) | ||
.spec(Schema.SchemaSpec.builder() | ||
.schema( | ||
"{\"namespace\":\"com.michelin.kafka.producer.showcase.avro\",\"type\":\"record\"," | ||
+ "\"name\":\"PersonAvro\",\"fields\":[" | ||
+ "{\"name\":\"field1\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field2\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field3\",\"type\":[\"null\",\"string\"]}]}") | ||
.build()) | ||
.build(); | ||
|
||
// Register V3 schema | ||
var createV3Response = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.POST, "/api/namespaces/ns1/schemas") | ||
.bearerAuth(token) | ||
.body(schemaV3), Schema.class); | ||
|
||
assertEquals("created", createV3Response.header("X-Ns4kafka-Result")); | ||
|
||
Schema schemaV4 = Schema.builder() | ||
.metadata(Metadata.builder() | ||
.name("ns1-subject4-value") | ||
.build()) | ||
.spec(Schema.SchemaSpec.builder() | ||
.schema( | ||
"{\"namespace\":\"com.michelin.kafka.producer.showcase.avro\",\"type\":\"record\"," | ||
+ "\"name\":\"PersonAvro\",\"fields\":[" | ||
+ "{\"name\":\"field1\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field2\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field3\",\"type\":[\"null\",\"string\"]}," | ||
+ "{\"name\":\"field4\",\"type\":[\"null\",\"string\"]}]}") | ||
.build()) | ||
.build(); | ||
|
||
// Register V4 schema | ||
var createV4Response = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.POST, "/api/namespaces/ns1/schemas") | ||
.bearerAuth(token) | ||
.body(schemaV4), Schema.class); | ||
|
||
assertEquals("created", createV4Response.header("X-Ns4kafka-Result")); | ||
|
||
// Delete latest schema version | ||
var deleteLatestVersionResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.DELETE, "/api/namespaces/ns1/schemas/ns1-subject3-value?version=latest") | ||
.create(HttpMethod.DELETE, "/api/namespaces/ns1/schemas/ns1-subject4-value?version=latest") | ||
.bearerAuth(token), Schema.class); | ||
|
||
assertEquals(HttpStatus.NO_CONTENT, deleteLatestVersionResponse.getStatus()); | ||
|
@@ -780,26 +878,18 @@ void shouldRegisterSameSchemaTwice() { | |
var getSchemaAfterLatestVersionDeletionResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.GET, "/api/namespaces/ns1/schemas/ns1-subject3-value") | ||
.create(HttpMethod.GET, "/api/namespaces/ns1/schemas/ns1-subject4-value") | ||
.bearerAuth(token), Schema.class); | ||
|
||
// Expects v1 is returned by ns4kafka | ||
// Expects v3 is returned by ns4kafka | ||
assertTrue(getSchemaAfterLatestVersionDeletionResponse.getBody().isPresent()); | ||
assertEquals(1, getSchemaAfterLatestVersionDeletionResponse.getBody().get().getSpec().getVersion()); | ||
|
||
// Post the v2 schema again | ||
ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.POST, "/api/namespaces/ns1/schemas") | ||
.bearerAuth(token) | ||
.body(sameSchemaWithSwappedFields), Schema.class); | ||
assertEquals(3, getSchemaAfterLatestVersionDeletionResponse.getBody().get().getSpec().getVersion()); | ||
|
||
// Delete old schema version | ||
var deleteOldVersionResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.DELETE, "/api/namespaces/ns1/schemas/ns1-subject3-value?version=1") | ||
.create(HttpMethod.DELETE, "/api/namespaces/ns1/schemas/ns1-subject4-value?version=1") | ||
.bearerAuth(token), Schema.class); | ||
|
||
assertEquals(HttpStatus.NO_CONTENT, deleteOldVersionResponse.getStatus()); | ||
|
@@ -808,11 +898,30 @@ void shouldRegisterSameSchemaTwice() { | |
var getSchemaAfterOldVersionDeletionResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.GET, "/api/namespaces/ns1/schemas/ns1-subject3-value") | ||
.create(HttpMethod.GET, "/api/namespaces/ns1/schemas/ns1-subject4-value") | ||
.bearerAuth(token), Schema.class); | ||
|
||
// Expects v2 as returned schema | ||
// Expects v3 as returned schema | ||
assertTrue(getSchemaAfterOldVersionDeletionResponse.getBody().isPresent()); | ||
assertEquals(2, getSchemaAfterOldVersionDeletionResponse.getBody().get().getSpec().getVersion()); | ||
assertEquals(3, getSchemaAfterOldVersionDeletionResponse.getBody().get().getSpec().getVersion()); | ||
|
||
// Delete all remaining schema versions | ||
var deleteAllVersionsResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.DELETE, "/api/namespaces/ns1/schemas/ns1-subject4-value") | ||
.bearerAuth(token), Schema.class); | ||
|
||
assertEquals(HttpStatus.NO_CONTENT, deleteAllVersionsResponse.getStatus()); | ||
|
||
// Get all schemas | ||
var getSchemaAfterAllVersionsDeletionResponse = ns4KafkaClient | ||
.toBlocking() | ||
.exchange(HttpRequest | ||
.create(HttpMethod.GET, "/api/namespaces/ns1/schemas/ns1-subject4-value") | ||
.bearerAuth(token), Schema.class); | ||
|
||
// Expects no returned schema | ||
assertTrue(getSchemaAfterAllVersionsDeletionResponse.getBody().isEmpty()); | ||
} | ||
} |