Search in sources :

Example 1 with SchemaManager

use of io.confluent.kafkarest.controllers.SchemaManager in project kafka-rest by confluentinc.

the class ProduceActionTest method getProduceAction.

private static ProduceAction getProduceAction(ProduceRateLimiters produceRateLimiters, ChunkedOutputFactory chunkedOutputFactory, int times, int producerId, boolean errorSchemaRegistry) {
    Provider<SchemaManager> schemaManagerProvider = mock(Provider.class);
    SchemaManager schemaManagerMock = mock(SchemaManager.class);
    expect(schemaManagerProvider.get()).andReturn(schemaManagerMock);
    expect(schemaManagerMock.getSchema("topicName", Optional.of(EmbeddedFormat.AVRO), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of("bob"), true)).andThrow(Errors.invalidPayloadException("Schema Registry must be configured when using schemas."));
    replay(schemaManagerProvider, schemaManagerMock);
    Provider<ProducerMetrics> producerMetricsProvider = mock(Provider.class);
    getProducerMetricsProvider(producerMetricsProvider);
    Provider<RecordSerializer> recordSerializerProvider = getRecordSerializerProvider(errorSchemaRegistry);
    Provider<ProduceController> produceControllerProvider = mock(Provider.class);
    ProduceController produceController = getProduceControllerMock(produceControllerProvider);
    setupExpectsMockCallsForProduce(produceController, times, producerId);
    replay(producerMetricsProvider, produceControllerProvider, produceController);
    StreamingResponseFactory streamingResponseFactory = new StreamingResponseFactory(chunkedOutputFactory);
    // get the current thread so that the call counts can be seen by easy mock
    ExecutorService executorService = MoreExecutors.newDirectExecutorService();
    ProduceAction produceAction = new ProduceAction(schemaManagerProvider, recordSerializerProvider, produceControllerProvider, producerMetricsProvider, streamingResponseFactory, produceRateLimiters, executorService);
    produceRateLimiters.clear();
    return produceAction;
}
Also used : ProduceController(io.confluent.kafkarest.controllers.ProduceController) StreamingResponseFactory(io.confluent.kafkarest.response.StreamingResponseFactory) ExecutorService(java.util.concurrent.ExecutorService) SchemaManager(io.confluent.kafkarest.controllers.SchemaManager) ProducerMetrics(io.confluent.kafkarest.ProducerMetrics) RecordSerializer(io.confluent.kafkarest.controllers.RecordSerializer)

Aggregations

ProducerMetrics (io.confluent.kafkarest.ProducerMetrics)1 ProduceController (io.confluent.kafkarest.controllers.ProduceController)1 RecordSerializer (io.confluent.kafkarest.controllers.RecordSerializer)1 SchemaManager (io.confluent.kafkarest.controllers.SchemaManager)1 StreamingResponseFactory (io.confluent.kafkarest.response.StreamingResponseFactory)1 ExecutorService (java.util.concurrent.ExecutorService)1