Search in sources :

Example 1 with SchemaPartitionProduceRequest

use of io.confluent.kafkarest.entities.v2.SchemaPartitionProduceRequest in project kafka-rest by confluentinc.

the class AvroProducerTest method testProduceToPartition.

protected <K, V> void testProduceToPartition(List<SchemaPartitionProduceRecord> records, List<PartitionOffset> offsetResponse, Map<String, String> queryParams) {
    SchemaPartitionProduceRequest payload = SchemaPartitionProduceRequest.create(records, /* keySchema= */
    null, /* keySchemaId= */
    null, /* valueSchema= */
    valueSchemaStr, /* valueSchemaId= */
    null);
    Response response = request("/topics/" + topicName + "/partitions/0", queryParams).post(Entity.entity(payload, Versions.KAFKA_V2_JSON_AVRO));
    assertOKResponse(response, Versions.KAFKA_V2_JSON);
    final ProduceResponse poffsetResponse = TestUtils.tryReadEntityOrLog(response, ProduceResponse.class);
    assertEquals(offsetResponse, poffsetResponse.getOffsets());
    TestUtils.assertTopicContains(plaintextBrokerList, topicName, payload.toProduceRequest().getRecords(), 0, KafkaAvroDeserializer.class.getName(), KafkaAvroDeserializer.class.getName(), deserializerProps, false);
    assertEquals((Integer) 1, poffsetResponse.getValueSchemaId());
}
Also used : ProduceResponse(io.confluent.kafkarest.entities.v2.ProduceResponse) TestUtils.assertOKResponse(io.confluent.kafkarest.TestUtils.assertOKResponse) Response(javax.ws.rs.core.Response) SchemaPartitionProduceRequest(io.confluent.kafkarest.entities.v2.SchemaPartitionProduceRequest) ProduceResponse(io.confluent.kafkarest.entities.v2.ProduceResponse) KafkaAvroDeserializer(io.confluent.kafka.serializers.KafkaAvroDeserializer)

Aggregations

KafkaAvroDeserializer (io.confluent.kafka.serializers.KafkaAvroDeserializer)1 TestUtils.assertOKResponse (io.confluent.kafkarest.TestUtils.assertOKResponse)1 ProduceResponse (io.confluent.kafkarest.entities.v2.ProduceResponse)1 SchemaPartitionProduceRequest (io.confluent.kafkarest.entities.v2.SchemaPartitionProduceRequest)1 Response (javax.ws.rs.core.Response)1