Skip to content

Commit

Permalink
Extend schema registry tests
Browse files Browse the repository at this point in the history
Schema registry tests for publishing and consuming new schemas.

The tests only cover the api availability. Further reference should follow the official documentation as this is a quite extensive / complex subject, which would require code generation, plugins to have as example while the [official documentation](https://docs.confluent.io/platform/current/schema-registry/index.html) is quite good.
  • Loading branch information
gustavo.monarin committed Oct 19, 2022
1 parent 9107005 commit 17ce951
Showing 1 changed file with 16 additions and 3 deletions.
Expand Up @@ -27,6 +27,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
import static org.hamcrest.Matchers.hasItems;

public class RedpandaContainerTest {

Expand Down Expand Up @@ -77,9 +78,21 @@ public void testSchemaRegistry() {
// }
);

io.restassured.response.Response subjects = RestAssured.given().when().get(subjectsEndpoint).andReturn();

assertThat(subjects.getStatusCode()).isEqualTo(200);
String subjectName = String.format("test-%s-value", UUID.randomUUID());

// register the new subject
RestAssured
.given()
.contentType("application/vnd.schemaregistry.v1+json")
.pathParam("subject", subjectName)
.body("{\"schema\": \"{\\\"type\\\": \\\"string\\\"}\"}")
.when()
.post(subjectsEndpoint + "/{subject}/versions")
.then()
.statusCode(200);

// list all the registered subjects
RestAssured.given().when().get(subjectsEndpoint).then().statusCode(200).body("$", hasItems(subjectName));
}
}

Expand Down

0 comments on commit 17ce951

Please sign in to comment.