use of io.confluent.rest.exceptions.RestConstraintViolationException in project kafka-rest by confluentinc.
the class SchemaManagerImplTest method getSchema_avro_schemaId_schemaIdNotInSubject.
@Test
public void getSchema_avro_schemaId_schemaIdNotInSubject() throws Exception {
ParsedSchema schema = new AvroSchema("{\"type\": \"int\"}");
int schemaId = schemaRegistryClient.register("foobar", schema);
RestConstraintViolationException rcve = assertThrows(RestConstraintViolationException.class, () -> schemaManager.getSchema(TOPIC_NAME, /* format= */
Optional.empty(), /* subject= */
Optional.empty(), /* subjectNameStrategy= */
Optional.empty(), /* schemaId= */
Optional.of(schemaId), /* schemaVersion= */
Optional.empty(), /* rawSchema= */
Optional.empty(), /* isKey= */
true));
assertEquals("Error serializing message. Error when fetching schema version. subject = topic-1-key, schema = \"int\"\n" + "Subject Not Found; error code: 40401", rcve.getMessage());
assertEquals(42207, rcve.getErrorCode());
}
use of io.confluent.rest.exceptions.RestConstraintViolationException in project kafka-rest by confluentinc.
the class SchemaManagerImplTest method getSchema_avro_latestSchema_noSchema.
@Test
public void getSchema_avro_latestSchema_noSchema() {
RestConstraintViolationException rcve = assertThrows(RestConstraintViolationException.class, () -> schemaManager.getSchema(TOPIC_NAME, /* format= */
Optional.empty(), /* subject= */
Optional.empty(), /* subjectNameStrategy= */
Optional.empty(), /* schemaId= */
Optional.empty(), /* schemaVersion= */
Optional.empty(), /* rawSchema= */
Optional.empty(), /* isKey= */
true));
assertEquals("Error serializing message. Error when fetching latest schema version. subject = topic-1-key\n" + "Subject Not Found; error code: 40401", rcve.getMessage());
assertEquals(42207, rcve.getErrorCode());
}
use of io.confluent.rest.exceptions.RestConstraintViolationException in project kafka-rest by confluentinc.
the class SchemaManagerImplTest method getSchema_jsonschema_rawSchema_invalidSchema.
@Test
public void getSchema_jsonschema_rawSchema_invalidSchema() {
RestConstraintViolationException rcve = assertThrows(RestConstraintViolationException.class, () -> schemaManager.getSchema(TOPIC_NAME, /* format= */
Optional.of(EmbeddedFormat.JSONSCHEMA), /* subject= */
Optional.empty(), /* subjectNameStrategy= */
Optional.empty(), /* schemaId= */
Optional.empty(), /* schemaVersion= */
Optional.empty(), /* rawSchema= */
Optional.of("foobar"), /* isKey= */
true));
assertEquals("Invalid schema: Error when parsing raw schema. format = JSONSCHEMA, schema = foobar", rcve.getMessage());
assertEquals(42205, rcve.getErrorCode());
}
use of io.confluent.rest.exceptions.RestConstraintViolationException in project kafka-rest by confluentinc.
the class SchemaRecordSerializerTest method errorWhenNoSchemaRegistryDefined.
@Test
public void errorWhenNoSchemaRegistryDefined() {
SchemaRecordSerializer schemaRecordSerializer = new SchemaRecordSerializerThrowing();
RestConstraintViolationException rcve = assertThrows(RestConstraintViolationException.class, () -> schemaRecordSerializer.serialize(EmbeddedFormat.AVRO, "topic", Optional.empty(), null, true));
assertEquals(42207, rcve.getErrorCode());
assertEquals("Error serializing message. Schema Registry not defined, no Schema Registry client available to serialize message.", rcve.getMessage());
}
use of io.confluent.rest.exceptions.RestConstraintViolationException in project kafka-rest by confluentinc.
the class RecordSerializerFacadeTest method noSchemaRegistryClientConfigured.
@Test
public void noSchemaRegistryClientConfigured() {
RecordSerializerFacade myRecordSerializer = new RecordSerializerFacade(new NoSchemaRecordSerializer(SCHEMA_SERIALIZER_CONFIGS), () -> new SchemaRecordSerializerThrowing());
RestConstraintViolationException rcve = assertThrows(RestConstraintViolationException.class, () -> myRecordSerializer.serialize(EmbeddedFormat.AVRO, TOPIC_NAME, /* schema= */
Optional.empty(), TextNode.valueOf(BaseEncoding.base64().encode("foobar".getBytes(StandardCharsets.UTF_8))), /* isKey= */
true));
assertEquals("Error serializing message. Schema Registry not defined, no Schema Registry client available to serialize message.", rcve.getMessage());
assertEquals(42207, rcve.getErrorCode());
}
Aggregations