Search in sources :

Example 1 with CommandHandlers

use of org.eclipse.hono.client.command.CommandHandlers in project hono by eclipse.

the class ProtonBasedInternalCommandConsumerTest method setUp.

/**
 * Sets up fixture.
 */
@BeforeEach
public void setUp() {
    final HonoConnection honoConnection = AmqpClientUnitTestHelper.mockHonoConnection(mock(Vertx.class));
    final String adapterInstanceId = "adapterInstanceId";
    commandHandlers = new CommandHandlers();
    internalCommandConsumer = new ProtonBasedInternalCommandConsumer(honoConnection, adapterInstanceId, commandHandlers);
    context = VertxMockSupport.mockContext(mock(Vertx.class));
}
Also used : HonoConnection(org.eclipse.hono.client.HonoConnection) CommandHandlers(org.eclipse.hono.client.command.CommandHandlers) Vertx(io.vertx.core.Vertx) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CommandHandlers

use of org.eclipse.hono.client.command.CommandHandlers 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);
}
Also used : Buffer(io.vertx.core.buffer.Buffer) CommandHandlers(org.eclipse.hono.client.command.CommandHandlers) Tracer(io.opentracing.Tracer) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CommandResponse(org.eclipse.hono.client.command.CommandResponse) Admin(org.apache.kafka.clients.admin.Admin) Span(io.opentracing.Span) TenantObject(org.eclipse.hono.util.TenantObject) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) TenantClient(org.eclipse.hono.client.registry.TenantClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CommandHandlers (org.eclipse.hono.client.command.CommandHandlers)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Span (io.opentracing.Span)1 Tracer (io.opentracing.Tracer)1 Vertx (io.vertx.core.Vertx)1 Buffer (io.vertx.core.buffer.Buffer)1 Admin (org.apache.kafka.clients.admin.Admin)1 HonoConnection (org.eclipse.hono.client.HonoConnection)1 CommandResponse (org.eclipse.hono.client.command.CommandResponse)1 CommandResponseSender (org.eclipse.hono.client.command.CommandResponseSender)1 TenantClient (org.eclipse.hono.client.registry.TenantClient)1 RegistrationAssertion (org.eclipse.hono.util.RegistrationAssertion)1 TenantObject (org.eclipse.hono.util.TenantObject)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1