Search in sources :

Example 6 with CommandResponseSender

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

the class KafkaBasedInternalCommandConsumerTest method testHandleCommandMessageSendErrorResponse.

/**
 * Verifies that an error response is sent to the application if the tenant of the target device
 * is unknown or cannot be retrieved.
 */
@ParameterizedTest
@ValueSource(ints = { HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_UNAVAILABLE })
void testHandleCommandMessageSendErrorResponse(final int tenantServiceErrorCode) {
    final String tenantId = "myTenant";
    final String deviceId = "4711";
    final String subject = "subject";
    final Handler<CommandContext> commandHandler = VertxMockSupport.mockHandler();
    commandHandlers.putCommandHandler(tenantId, deviceId, null, commandHandler, context);
    when(tenantClient.get(eq("myTenant"), any())).thenReturn(Future.failedFuture(ServiceInvocationException.create(tenantServiceErrorCode)));
    final KafkaConsumerRecord<String, Buffer> commandRecord = getCommandRecord(deviceId, getHeaders(tenantId, deviceId, subject, 0L));
    internalCommandConsumer.handleCommandMessage(commandRecord);
    verify(commandHandler, never()).handle(any(KafkaBasedCommandContext.class));
    verify(commandResponseSender).sendCommandResponse(argThat(t -> t.getTenantId().equals("myTenant")), argThat(r -> r.getDeviceId().equals("4711")), argThat(cr -> cr.getStatus() == tenantServiceErrorCode), any());
}
Also used : Buffer(io.vertx.core.buffer.Buffer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HttpURLConnection(java.net.HttpURLConnection) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) ServiceInvocationException(org.eclipse.hono.client.ServiceInvocationException) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) Context(io.vertx.core.Context) ArrayList(java.util.ArrayList) ArgumentCaptor(org.mockito.ArgumentCaptor) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Admin(org.apache.kafka.clients.admin.Admin) TracingMockSupport(org.eclipse.hono.test.TracingMockSupport) CommandHandlers(org.eclipse.hono.client.command.CommandHandlers) KafkaClientUnitTestHelper(org.eclipse.hono.kafka.test.KafkaClientUnitTestHelper) ValueSource(org.junit.jupiter.params.provider.ValueSource) InOrder(org.mockito.InOrder) Tracer(io.opentracing.Tracer) CommandContext(org.eclipse.hono.client.command.CommandContext) Vertx(io.vertx.core.Vertx) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) Mockito.when(org.mockito.Mockito.when) KafkaRecordHelper(org.eclipse.hono.client.kafka.KafkaRecordHelper) TenantClient(org.eclipse.hono.client.registry.TenantClient) Truth.assertThat(com.google.common.truth.Truth.assertThat) Future(io.vertx.core.Future) Mockito.verify(org.mockito.Mockito.verify) CommandResponse(org.eclipse.hono.client.command.CommandResponse) TenantObject(org.eclipse.hono.util.TenantObject) Test(org.junit.jupiter.api.Test) HonoTopic(org.eclipse.hono.client.kafka.HonoTopic) Mockito.never(org.mockito.Mockito.never) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Buffer(io.vertx.core.buffer.Buffer) VertxMockSupport(org.eclipse.hono.test.VertxMockSupport) KafkaConsumerRecord(io.vertx.kafka.client.consumer.KafkaConsumerRecord) Mockito.inOrder(org.mockito.Mockito.inOrder) Span(io.opentracing.Span) KafkaConsumer(io.vertx.kafka.client.consumer.KafkaConsumer) Handler(io.vertx.core.Handler) KafkaHeader(io.vertx.kafka.client.producer.KafkaHeader) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) CommandContext(org.eclipse.hono.client.command.CommandContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with CommandResponseSender

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

the class AbstractProtocolAdapterApplication method setCollaborators.

/**
 * Sets collaborators required by all protocol adapters.
 *
 * @param adapter The adapter to set the collaborators on.
 * @throws NullPointerException if adapter is {@code null}
 * @throws IllegalStateException if no connection to the Command Router service has been configured.
 */
protected void setCollaborators(final AbstractProtocolAdapterBase<?> adapter) {
    Objects.requireNonNull(adapter);
    final DeviceRegistrationClient registrationClient = registrationClient();
    final MessagingClientProvider<TelemetrySender> telemetrySenderProvider = new MessagingClientProvider<>();
    final MessagingClientProvider<EventSender> eventSenderProvider = new MessagingClientProvider<>();
    final MessagingClientProvider<CommandResponseSender> commandResponseSenderProvider = new MessagingClientProvider<>();
    final KafkaClientMetricsSupport kafkaClientMetricsSupport = kafkaClientMetricsSupport(kafkaMetricsOptions);
    final var tenantClient = tenantClient();
    if (kafkaEventConfig.isConfigured()) {
        LOG.info("Kafka client configuration present, adding Kafka messaging clients");
        final KafkaProducerFactory<String, Buffer> factory = CachingKafkaProducerFactory.sharedFactory(vertx);
        factory.setMetricsSupport(kafkaClientMetricsSupport);
        telemetrySenderProvider.setClient(new KafkaBasedTelemetrySender(vertx, factory, kafkaTelemetryConfig, protocolAdapterProperties.isDefaultsEnabled(), tracer));
        eventSenderProvider.setClient(new KafkaBasedEventSender(vertx, factory, kafkaEventConfig, protocolAdapterProperties.isDefaultsEnabled(), tracer));
        commandResponseSenderProvider.setClient(new KafkaBasedCommandResponseSender(vertx, factory, kafkaCommandResponseConfig, tracer));
    }
    if (downstreamSenderConfig.isHostConfigured()) {
        telemetrySenderProvider.setClient(downstreamSender());
        eventSenderProvider.setClient(downstreamSender());
        commandResponseSenderProvider.setClient(new ProtonBasedCommandResponseSender(HonoConnection.newConnection(vertx, commandResponseSenderConfig(), tracer), messageSamplerFactory, protocolAdapterProperties.isJmsVendorPropsEnabled()));
    }
    final MessagingClientProviders messagingClientProviders = new MessagingClientProviders(telemetrySenderProvider, eventSenderProvider, commandResponseSenderProvider);
    if (commandRouterConfig.isHostConfigured()) {
        final CommandRouterClient commandRouterClient = commandRouterClient();
        adapter.setCommandRouterClient(commandRouterClient);
        final CommandRouterCommandConsumerFactory commandConsumerFactory = commandConsumerFactory(commandRouterClient);
        if (commandConsumerConfig.isHostConfigured()) {
            commandConsumerFactory.registerInternalCommandConsumer((id, handlers) -> new ProtonBasedInternalCommandConsumer(commandConsumerConnection(), id, handlers));
        }
        final CommandResponseSender kafkaCommandResponseSender = messagingClientProviders.getCommandResponseSenderProvider().getClient(MessagingType.kafka);
        if (kafkaCommandInternalConfig.isConfigured() && kafkaCommandConfig.isConfigured() && kafkaCommandResponseSender != null) {
            commandConsumerFactory.registerInternalCommandConsumer((id, handlers) -> new KafkaBasedInternalCommandConsumer(vertx, kafkaCommandInternalConfig, kafkaCommandConfig, tenantClient, kafkaCommandResponseSender, id, handlers, tracer).setMetricsSupport(kafkaClientMetricsSupport));
        }
        adapter.setCommandConsumerFactory(commandConsumerFactory);
    } else {
        throw new IllegalStateException("No Command Router connection configured");
    }
    adapter.setMessagingClientProviders(messagingClientProviders);
    Optional.ofNullable(connectionEventProducer()).ifPresent(adapter::setConnectionEventProducer);
    adapter.setCredentialsClient(credentialsClient());
    adapter.setHealthCheckServer(healthCheckServer);
    adapter.setRegistrationClient(registrationClient);
    adapter.setResourceLimitChecks(prometheusResourceLimitChecks(resourceLimitChecksConfig, tenantClient));
    adapter.setTenantClient(tenantClient);
    adapter.setTracer(tracer);
}
Also used : Buffer(io.vertx.core.buffer.Buffer) KafkaBasedTelemetrySender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedTelemetrySender) CommandRouterClient(org.eclipse.hono.client.command.CommandRouterClient) ProtonBasedCommandRouterClient(org.eclipse.hono.client.command.amqp.ProtonBasedCommandRouterClient) KafkaBasedCommandResponseSender(org.eclipse.hono.client.command.kafka.KafkaBasedCommandResponseSender) ProtonBasedDeviceRegistrationClient(org.eclipse.hono.client.registry.amqp.ProtonBasedDeviceRegistrationClient) DeviceRegistrationClient(org.eclipse.hono.client.registry.DeviceRegistrationClient) ProtonBasedCommandResponseSender(org.eclipse.hono.client.command.amqp.ProtonBasedCommandResponseSender) KafkaBasedEventSender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedEventSender) MicrometerKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.MicrometerKafkaClientMetricsSupport) KafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.KafkaClientMetricsSupport) NoopKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.NoopKafkaClientMetricsSupport) CommandRouterCommandConsumerFactory(org.eclipse.hono.client.command.CommandRouterCommandConsumerFactory) MessagingClientProviders(org.eclipse.hono.adapter.MessagingClientProviders) MessagingClientProvider(org.eclipse.hono.client.util.MessagingClientProvider) KafkaBasedInternalCommandConsumer(org.eclipse.hono.client.command.kafka.KafkaBasedInternalCommandConsumer) KafkaBasedCommandResponseSender(org.eclipse.hono.client.command.kafka.KafkaBasedCommandResponseSender) ProtonBasedCommandResponseSender(org.eclipse.hono.client.command.amqp.ProtonBasedCommandResponseSender) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) KafkaBasedEventSender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedEventSender) EventSender(org.eclipse.hono.client.telemetry.EventSender) ProtonBasedInternalCommandConsumer(org.eclipse.hono.client.command.amqp.ProtonBasedInternalCommandConsumer) TelemetrySender(org.eclipse.hono.client.telemetry.TelemetrySender) KafkaBasedTelemetrySender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedTelemetrySender)

Example 8 with CommandResponseSender

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

the class KafkaBasedInternalCommandConsumer method handleCommandMessage.

void handleCommandMessage(final KafkaConsumerRecord<String, Buffer> record) {
    // get partition/offset of the command record - related to the tenant-based topic the command was originally received in
    final Integer commandPartition = KafkaRecordHelper.getOriginalPartitionHeader(record.headers()).orElse(null);
    final Long commandOffset = KafkaRecordHelper.getOriginalOffsetHeader(record.headers()).orElse(null);
    if (commandPartition == null || commandOffset == null) {
        LOG.warn("command record is invalid - missing required original partition/offset headers");
        return;
    }
    final KafkaBasedCommand command;
    try {
        command = KafkaBasedCommand.fromRoutedCommandRecord(record);
    } catch (final IllegalArgumentException e) {
        LOG.warn("command record is invalid [tenant-id: {}, device-id: {}]", KafkaRecordHelper.getTenantId(record.headers()).orElse(null), KafkaRecordHelper.getDeviceId(record.headers()).orElse(null), e);
        return;
    }
    // check whether command has already been received and handled;
    // partition index and offset here are related to the *tenant-based* topic the command was originally received in
    // therefore they are stored in a map with the tenant as key
    final Map<Integer, Long> lastHandledPartitionOffsets = lastHandledPartitionOffsetsPerTenant.computeIfAbsent(command.getTenant(), k -> new HashMap<>());
    final Long lastHandledOffset = lastHandledPartitionOffsets.get(commandPartition);
    if (lastHandledOffset != null && commandOffset <= lastHandledOffset) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("ignoring command - record partition offset {} <= last handled offset {} [{}]", commandOffset, lastHandledOffset, command);
        }
    } else {
        lastHandledPartitionOffsets.put(commandPartition, commandOffset);
        final CommandHandlerWrapper commandHandler = commandHandlers.getCommandHandler(command.getTenant(), command.getGatewayOrDeviceId());
        if (commandHandler != null && commandHandler.getGatewayId() != null) {
            // Gateway information set in command handler means a gateway has subscribed for commands for a specific device.
            // This information isn't getting set in the record (by the Command Router) and therefore has to be adopted manually here.
            command.setGatewayId(commandHandler.getGatewayId());
        }
        final SpanContext spanContext = KafkaTracingHelper.extractSpanContext(tracer, record);
        final SpanContext followsFromSpanContext = commandHandler != null ? commandHandler.getConsumerCreationSpanContext() : null;
        final Span currentSpan = CommandContext.createSpan(tracer, command, spanContext, followsFromSpanContext, getClass().getSimpleName());
        currentSpan.setTag(MessageHelper.APP_PROPERTY_ADAPTER_INSTANCE_ID, adapterInstanceId);
        KafkaTracingHelper.TAG_OFFSET.set(currentSpan, record.offset());
        final var commandContext = new KafkaBasedCommandContext(command, commandResponseSender, currentSpan);
        tenantClient.get(command.getTenant(), spanContext).onFailure(t -> {
            if (ServiceInvocationException.extractStatusCode(t) == HttpURLConnection.HTTP_NOT_FOUND) {
                commandContext.reject(new TenantDisabledOrNotRegisteredException(command.getTenant(), HttpURLConnection.HTTP_NOT_FOUND));
            } else {
                commandContext.release(new ServerErrorException(command.getTenant(), HttpURLConnection.HTTP_UNAVAILABLE, "error retrieving tenant configuration", t));
            }
        }).onSuccess(tenantConfig -> {
            commandContext.put(CommandContext.KEY_TENANT_CONFIG, tenantConfig);
            if (commandHandler != null) {
                LOG.trace("using [{}] for received command [{}]", commandHandler, command);
                // command.isValid() check not done here - it is to be done in the command handler
                commandHandler.handleCommand(commandContext);
            } else {
                LOG.info("no command handler found for command [{}]", command);
                commandContext.release(new NoConsumerException("no command handler found for command"));
            }
        });
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) MessagingKafkaConsumerConfigProperties(org.eclipse.hono.client.kafka.consumer.MessagingKafkaConsumerConfigProperties) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CommandHandlerWrapper(org.eclipse.hono.client.command.CommandHandlerWrapper) TenantDisabledOrNotRegisteredException(org.eclipse.hono.client.registry.TenantDisabledOrNotRegisteredException) ServiceInvocationException(org.eclipse.hono.client.ServiceInvocationException) Supplier(java.util.function.Supplier) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) KafkaClientFactory(org.eclipse.hono.client.kafka.KafkaClientFactory) Context(io.vertx.core.Context) NoConsumerException(org.eclipse.hono.client.NoConsumerException) CompositeFuture(io.vertx.core.CompositeFuture) Status(io.vertx.ext.healthchecks.Status) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) KafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.KafkaClientMetricsSupport) Map(java.util.Map) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) Admin(org.apache.kafka.clients.admin.Admin) CommandHandlers(org.eclipse.hono.client.command.CommandHandlers) KafkaTracingHelper(org.eclipse.hono.client.kafka.tracing.KafkaTracingHelper) CommonClientConfigs(org.apache.kafka.clients.CommonClientConfigs) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Promise(io.vertx.core.Promise) NewTopic(org.apache.kafka.clients.admin.NewTopic) CommandContext(org.eclipse.hono.client.command.CommandContext) Vertx(io.vertx.core.Vertx) Set(java.util.Set) ServerErrorException(org.eclipse.hono.client.ServerErrorException) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) KafkaRecordHelper(org.eclipse.hono.client.kafka.KafkaRecordHelper) TenantClient(org.eclipse.hono.client.registry.TenantClient) MessageHelper(org.eclipse.hono.util.MessageHelper) Future(io.vertx.core.Future) InternalCommandConsumer(org.eclipse.hono.client.command.InternalCommandConsumer) SpanContext(io.opentracing.SpanContext) TopicPartition(io.vertx.kafka.client.common.TopicPartition) Objects(java.util.Objects) HonoTopic(org.eclipse.hono.client.kafka.HonoTopic) List(java.util.List) TopicExistsException(org.apache.kafka.common.errors.TopicExistsException) Buffer(io.vertx.core.buffer.Buffer) KafkaConsumerRecord(io.vertx.kafka.client.consumer.KafkaConsumerRecord) Optional(java.util.Optional) Span(io.opentracing.Span) KafkaConsumer(io.vertx.kafka.client.consumer.KafkaConsumer) SpanContext(io.opentracing.SpanContext) NoConsumerException(org.eclipse.hono.client.NoConsumerException) TenantDisabledOrNotRegisteredException(org.eclipse.hono.client.registry.TenantDisabledOrNotRegisteredException) Span(io.opentracing.Span) CommandHandlerWrapper(org.eclipse.hono.client.command.CommandHandlerWrapper) ServerErrorException(org.eclipse.hono.client.ServerErrorException)

Example 9 with CommandResponseSender

use of org.eclipse.hono.client.command.CommandResponseSender 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)

Example 10 with CommandResponseSender

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

the class CommandResponseResourceTest method testUploadCommandResponseFailsForDisabledTenant.

/**
 * Verifies that the adapter fails the upload of a command response with a 4.03
 * if the adapter is disabled for the device's tenant.
 *
 * @param ctx The vert.x test context.
 */
@Test
public void testUploadCommandResponseFailsForDisabledTenant(final VertxTestContext ctx) {
    // GIVEN an adapter
    givenAnAdapter(properties);
    final var resource = givenAResource(adapter);
    final Promise<Void> outcome = Promise.promise();
    final CommandResponseSender sender = givenACommandResponseSenderForAnyTenant(outcome);
    // that is not enabled for a device's tenant
    when(adapter.isAdapterEnabled(any(TenantObject.class))).thenReturn(Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_FORBIDDEN)));
    // WHEN a device publishes an command response
    final String reqId = Commands.encodeRequestIdParameters("correlation", "replyToId", "device", MessagingType.amqp);
    final Buffer payload = Buffer.buffer("some payload");
    final OptionSet options = new OptionSet();
    options.addUriPath(CommandConstants.COMMAND_RESPONSE_ENDPOINT).addUriPath(reqId);
    options.addUriQuery(String.format("%s=%d", Constants.HEADER_COMMAND_RESPONSE_STATUS, 200));
    options.setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
    final CoapExchange coapExchange = newCoapExchange(payload, Type.CON, options);
    final Device authenticatedDevice = new Device("tenant", "device");
    final CoapContext context = CoapContext.fromRequest(coapExchange, authenticatedDevice, authenticatedDevice, "device", span);
    resource.uploadCommandResponseMessage(context).onComplete(ctx.failing(t -> {
        ctx.verify(() -> {
            // THEN the command response has not been forwarded downstream
            verify(sender, never()).sendCommandResponse(any(TenantObject.class), any(RegistrationAssertion.class), any(CommandResponse.class), any(SpanContext.class));
            // and the device gets a 4.03 response
            assertThat(t).isInstanceOf(ClientErrorException.class);
            assertThat(((ClientErrorException) t).getErrorCode()).isEqualTo(HttpURLConnection.HTTP_FORBIDDEN);
            // and the response has not been reported as forwarded
            verify(metrics, never()).reportCommand(eq(Direction.RESPONSE), eq("tenant"), any(), eq(ProcessingOutcome.FORWARDED), anyInt(), any());
        });
        ctx.completeNow();
    }));
}
Also used : Buffer(io.vertx.core.buffer.Buffer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HttpURLConnection(java.net.HttpURLConnection) ResponseCode(org.eclipse.californium.core.coap.CoAP.ResponseCode) VertxTestContext(io.vertx.junit5.VertxTestContext) CoapExchange(org.eclipse.californium.core.server.resources.CoapExchange) Response(org.eclipse.californium.core.coap.Response) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) ClientErrorException(org.eclipse.hono.client.ClientErrorException) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) Commands(org.eclipse.hono.client.command.Commands) Constants(org.eclipse.hono.util.Constants) Timeout(io.vertx.junit5.Timeout) ProcessingOutcome(org.eclipse.hono.service.metric.MetricsTags.ProcessingOutcome) MessagingType(org.eclipse.hono.util.MessagingType) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) MediaTypeRegistry(org.eclipse.californium.core.coap.MediaTypeRegistry) CommandConstants(org.eclipse.hono.util.CommandConstants) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Type(org.eclipse.californium.core.coap.CoAP.Type) Direction(org.eclipse.hono.service.metric.MetricsTags.Direction) NoopTracerFactory(io.opentracing.noop.NoopTracerFactory) Promise(io.vertx.core.Promise) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) Mockito.when(org.mockito.Mockito.when) Truth.assertThat(com.google.common.truth.Truth.assertThat) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Device(org.eclipse.hono.auth.Device) Mockito.verify(org.mockito.Mockito.verify) CommandResponse(org.eclipse.hono.client.command.CommandResponse) TenantObject(org.eclipse.hono.util.TenantObject) SpanContext(io.opentracing.SpanContext) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Mockito.never(org.mockito.Mockito.never) Buffer(io.vertx.core.buffer.Buffer) OptionSet(org.eclipse.californium.core.coap.OptionSet) Device(org.eclipse.hono.auth.Device) TenantObject(org.eclipse.hono.util.TenantObject) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) ClientErrorException(org.eclipse.hono.client.ClientErrorException) OptionSet(org.eclipse.californium.core.coap.OptionSet) CoapExchange(org.eclipse.californium.core.server.resources.CoapExchange) Test(org.junit.jupiter.api.Test)

Aggregations

CommandResponseSender (org.eclipse.hono.client.command.CommandResponseSender)14 Buffer (io.vertx.core.buffer.Buffer)11 CommandResponse (org.eclipse.hono.client.command.CommandResponse)10 RegistrationAssertion (org.eclipse.hono.util.RegistrationAssertion)10 TenantObject (org.eclipse.hono.util.TenantObject)10 SpanContext (io.opentracing.SpanContext)9 Future (io.vertx.core.Future)9 HttpURLConnection (java.net.HttpURLConnection)9 Test (org.junit.jupiter.api.Test)9 Truth.assertThat (com.google.common.truth.Truth.assertThat)8 Promise (io.vertx.core.Promise)8 VertxTestContext (io.vertx.junit5.VertxTestContext)8 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)8 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)8 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)8 Mockito.never (org.mockito.Mockito.never)8 Mockito.verify (org.mockito.Mockito.verify)8 Mockito.when (org.mockito.Mockito.when)8 Span (io.opentracing.Span)7 Context (io.vertx.core.Context)7