ProtocolAdapterCommandConsumerFactoryImpl extends AbstractHonoClientFactory implements ProtocolAdapterCommandConsumerFactory { @Override public final Future<ProtocolAdapterCommandConsumer> createCommandConsumer(final String tenantId, final String deviceId, final Handler<CommandContext> commandHandler, final Duration lifespan, final SpanContext context) { Objects.requireNonNull(tenantId); Objects.requireNonNull(deviceId); Objects.requireNonNull(commandHandler); return doCreateCommandConsumer(tenantId, deviceId, null, commandHandler, lifespan, context); } ProtocolAdapterCommandConsumerFactoryImpl(final HonoConnection connection, final SendMessageSampler.Factory samplerFactory); @Override void initialize(final CommandTargetMapper commandTargetMapper,
            final BasicDeviceConnectionClientFactory deviceConnectionClientFactory); @Override final Future<ProtocolAdapterCommandConsumer> createCommandConsumer(final String tenantId, final String deviceId,
            final Handler<CommandContext> commandHandler, final Duration lifespan, final SpanContext context); @Override final Future<ProtocolAdapterCommandConsumer> createCommandConsumer(final String tenantId,
            final String deviceId, final String gatewayId, final Handler<CommandContext> commandHandler,
            final Duration lifespan, final SpanContext context); @Override Future<CommandResponseSender> getCommandResponseSender(final String tenantId, final String replyId);  }
@Test public void testCreateCommandConsumerFailsIfPeerRejectsLink(final VertxTestContext ctx) { final Handler<CommandContext> commandHandler = VertxMockSupport.mockHandler(); final ServerErrorException ex = new ServerErrorException(HttpURLConnection.HTTP_UNAVAILABLE); when(connection.createReceiver( anyString(), any(ProtonQoS.class), any(ProtonMessageHandler.class), anyInt(), anyBoolean(), VertxMockSupport.anyHandler())) .thenReturn(Future.failedFuture(ex)); commandConsumerFactory.createCommandConsumer(tenantId, deviceId, commandHandler, null, null) .onComplete(ctx.failing(t -> { ctx.verify(() -> assertThat(((ServiceInvocationException) t).getErrorCode()).isEqualTo(HttpURLConnection.HTTP_UNAVAILABLE)); ctx.completeNow(); })); }