use of io.opentracing.Tracer in project hono by eclipse.
the class KafkaBasedInternalCommandConsumerTest method setUp.
/**
* Sets up fixture.
*/
@BeforeEach
public void setUp() {
final Admin kafkaAdminClient = mock(Admin.class);
@SuppressWarnings("unchecked") final KafkaConsumer<String, Buffer> kafkaConsumer = mock(KafkaConsumer.class);
final String adapterInstanceId = "adapterInstanceId";
final Span span = TracingMockSupport.mockSpan();
final Tracer tracer = TracingMockSupport.mockTracer(span);
context = VertxMockSupport.mockContext(mock(Vertx.class));
commandHandlers = new CommandHandlers();
tenantClient = mock(TenantClient.class);
doAnswer(invocation -> {
final String tenantId = invocation.getArgument(0);
return Future.succeededFuture(TenantObject.from(tenantId));
}).when(tenantClient).get(anyString(), any());
commandResponseSender = mock(CommandResponseSender.class);
when(commandResponseSender.sendCommandResponse(any(TenantObject.class), any(RegistrationAssertion.class), any(CommandResponse.class), any())).thenReturn(Future.succeededFuture());
internalCommandConsumer = new KafkaBasedInternalCommandConsumer(context, kafkaAdminClient, kafkaConsumer, "testClientId", tenantClient, commandResponseSender, adapterInstanceId, commandHandlers, tracer);
}
use of io.opentracing.Tracer in project hono by eclipse.
the class MessageAnnotationsInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.
/**
* Verifies that the Jaeger tracer implementation can successfully use the adapter to inject and extract
* a SpanContext.
*/
@Test
public void testJaegerTracerCanUseAdapter() {
final Configuration config = new Configuration("test");
final Tracer tracer = config.getTracer();
final Span span = tracer.buildSpan("do").start();
final Message message = ProtonHelper.message();
final MessageAnnotationsInjectAdapter injectAdapter = new MessageAnnotationsInjectAdapter(message, propertiesMapName);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new MessageAnnotationsExtractAdapter(message, propertiesMapName));
assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
use of io.opentracing.Tracer in project hono by eclipse.
the class JsonObjectInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.
/**
* Verifies that the Jaeger tracer implementation can successfully use the adapter to inject and extract
* a SpanContext.
*/
@Test
public void testJaegerTracerCanUseAdapter() {
final Configuration config = new Configuration("test");
final Tracer tracer = config.getTracer();
final Span span = tracer.buildSpan("do").start();
final JsonObject jsonObject = new JsonObject();
final JsonObjectInjectAdapter injectAdapter = new JsonObjectInjectAdapter(jsonObject);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new JsonObjectExtractAdapter(jsonObject));
assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
use of io.opentracing.Tracer in project hono by eclipse.
the class MultiMapInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.
/**
* Verifies that the Jaeger tracer implementation can successfully use the adapter to inject and extract
* a SpanContext.
*/
@Test
public void testJaegerTracerCanUseAdapter() {
final Configuration config = new Configuration("test");
final Tracer tracer = config.getTracer();
final Span span = tracer.buildSpan("do").start();
final MultiMap multiMap = MultiMap.caseInsensitiveMultiMap();
final MultiMapInjectAdapter injectAdapter = new MultiMapInjectAdapter(multiMap);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new MultiMapExtractAdapter(multiMap));
assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
use of io.opentracing.Tracer in project hono by eclipse.
the class KafkaBasedMappingAndDelegatingCommandHandlerTest method setUp.
/**
* Sets up fixture.
*/
@BeforeEach
public void setUp() {
tenantId = UUID.randomUUID().toString();
deviceId = UUID.randomUUID().toString();
adapterInstanceId = UUID.randomUUID().toString();
final TenantClient tenantClient = mock(TenantClient.class);
when(tenantClient.get(eq(tenantId), any())).thenReturn(Future.succeededFuture(TenantObject.from(tenantId)));
commandTargetMapper = mock(CommandTargetMapper.class);
when(commandTargetMapper.getTargetGatewayAndAdapterInstance(eq(tenantId), eq(deviceId), any())).thenReturn(Future.succeededFuture(createTargetAdapterInstanceJson(deviceId, adapterInstanceId)));
internalCommandSender = mock(KafkaBasedInternalCommandSender.class);
when(internalCommandSender.sendCommand(any(CommandContext.class), anyString())).thenReturn(Future.succeededFuture());
final KafkaBasedCommandResponseSender kafkaBasedCommandResponseSender = mock(KafkaBasedCommandResponseSender.class);
vertx = mock(Vertx.class);
final Context context = VertxMockSupport.mockContext(vertx);
final KafkaCommandProcessingQueue commandQueue = new KafkaCommandProcessingQueue(context);
final CommandRouterMetrics metrics = mock(CommandRouterMetrics.class);
when(metrics.startTimer()).thenReturn(Timer.start());
final Tracer tracer = TracingMockSupport.mockTracer(TracingMockSupport.mockSpan());
cmdHandler = new KafkaBasedMappingAndDelegatingCommandHandler(vertx, tenantClient, commandQueue, commandTargetMapper, internalCommandSender, kafkaBasedCommandResponseSender, metrics, tracer);
}
Aggregations