Search in sources :

Example 6 with KafkaBasedCommandContext

use of org.eclipse.hono.client.command.kafka.KafkaBasedCommandContext in project hono by eclipse.

the class KafkaCommandProcessingQueueTest method getTestCommandContext.

@SuppressWarnings("unchecked")
private KafkaBasedCommandContext getTestCommandContext(final int offset) {
    final String deviceId = "deviceId";
    final List<KafkaHeader> headers = new ArrayList<>(List.of(KafkaRecordHelper.createDeviceIdHeader(deviceId), KafkaRecordHelper.createSubjectHeader("subject_" + offset), KafkaRecordHelper.createCorrelationIdHeader("correlationId")));
    final KafkaConsumerRecord<String, Buffer> consumerRecord = mock(KafkaConsumerRecord.class);
    when(consumerRecord.headers()).thenReturn(headers);
    when(consumerRecord.topic()).thenReturn(topic);
    when(consumerRecord.key()).thenReturn(deviceId);
    when(consumerRecord.offset()).thenReturn((long) offset);
    when(consumerRecord.partition()).thenReturn(0);
    final KafkaBasedCommand cmd = KafkaBasedCommand.from(consumerRecord);
    return new KafkaBasedCommandContext(cmd, mock(CommandResponseSender.class), mock(Span.class)) {

        @Override
        public String toString() {
            return "Command " + offset;
        }
    };
}
Also used : Buffer(io.vertx.core.buffer.Buffer) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) ArrayList(java.util.ArrayList) KafkaBasedCommand(org.eclipse.hono.client.command.kafka.KafkaBasedCommand) KafkaBasedCommandContext(org.eclipse.hono.client.command.kafka.KafkaBasedCommandContext) Span(io.opentracing.Span) KafkaHeader(io.vertx.kafka.client.producer.KafkaHeader)

Aggregations

Buffer (io.vertx.core.buffer.Buffer)6 KafkaBasedCommandContext (org.eclipse.hono.client.command.kafka.KafkaBasedCommandContext)6 Span (io.opentracing.Span)3 Future (io.vertx.core.Future)3 KafkaConsumerRecord (io.vertx.kafka.client.consumer.KafkaConsumerRecord)3 KafkaBasedCommand (org.eclipse.hono.client.command.kafka.KafkaBasedCommand)3 Test (org.junit.jupiter.api.Test)3 Context (io.vertx.core.Context)2 Promise (io.vertx.core.Promise)2 Vertx (io.vertx.core.Vertx)2 KafkaHeader (io.vertx.kafka.client.producer.KafkaHeader)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Objects (java.util.Objects)2 TopicPartition (org.apache.kafka.common.TopicPartition)2 ServerErrorException (org.eclipse.hono.client.ServerErrorException)2 CommandContext (org.eclipse.hono.client.command.CommandContext)2 CommandResponseSender (org.eclipse.hono.client.command.CommandResponseSender)2 CommandToBeReprocessedException (org.eclipse.hono.client.command.CommandToBeReprocessedException)2