AbstractSender extends AbstractHonoClient implements MessageSender { @Override public final Future<ProtonDelivery> send(final Message rawMessage) { return send(rawMessage, (SpanContext) null); } protected  AbstractSender(
            final HonoConnection connection,
            final ProtonSender sender,
            final String tenantId,
            final String targetAddress,
            final SendMessageSampler sampler); @Override final int getCredit(); @Override final void sendQueueDrainHandler(final Handler<Void> handler); @Override final void close(final Handler<AsyncResult<Void>> closeHandler); @Override final boolean isOpen(); @Override final Future<ProtonDelivery> send(final Message rawMessage); @Override final Future<ProtonDelivery> send(final Message rawMessage, final SpanContext parent);  }
@Test public void testSendMessageRemovesRegistrationAssertion() { when(protonSender.getRemoteOfferedCapabilities()).thenReturn(null); when(protonSender.send(any(Message.class), VertxMockSupport.anyHandler())).thenReturn(mock(ProtonDelivery.class)); final AbstractSender sender = newSender("tenant", "endpoint"); final Message msg = ProtonHelper.message("some payload"); msg.setContentType("application/text"); MessageHelper.addDeviceId(msg, "device"); sender.send(msg); final ArgumentCaptor<Message> sentMessage = ArgumentCaptor.forClass(Message.class); verify(protonSender).send(sentMessage.capture()); assertNull(MessageHelper.getAndRemoveRegistrationAssertion(sentMessage.getValue())); }
@Test public void testSendMessageFailsOnLackOfCredit() { when(protonSender.sendQueueFull()).thenReturn(Boolean.TRUE); final AbstractSender sender = newSender("tenant", "endpoint"); final Message msg = ProtonHelper.message("test"); final Future<ProtonDelivery> result = sender.send(msg); assertFalse(result.succeeded()); verify(protonSender, never()).send(any(Message.class)); }