Class MockedSender
java.lang.Object
fr.ght1pc9kc.testy.beat.messaging.MockedSender
Mocked sender injectable by the extension
WithRabbitMock
.
This sender allows publishing AMQP messages and RPC requests.
Usage:
@Test void my_test(MockedSender mockedSender) { final String request = "test-request"; final AmqpMessage message = AmqpMessage.of(request.getBytes()); mockedSender.basicPublish(message).on("my-exchange", "my-routing-key"); // Verify the tested consumer }
RPC requests can also be sent:
@Test void my_test(MockedSender mockedSender) { final String request = "test-request"; final AmqpMessage message = AmqpMessage.of(request.getBytes()); final Mono<Delivery> actualResponse = mockedSender.rpc(message).on("my-exchange", "my-routing-key"); // Verify the tested consumer and the response }
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Publisher build fromMockedSender
to simply publish an AMQP message.static final class
Publisher created byMockedSender
to publish a RPC request. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbasicPublish
(AmqpMessage message) Basically publish a message on an exchange.rpc
(AmqpMessage message) Send a RPC request with given message.
-
Constructor Details
-
MockedSender
public MockedSender(com.rabbitmq.client.Channel channel) Create the sender.- Parameters:
channel
- Channel where the messages are published.
-
-
Method Details
-
basicPublish
Basically publish a message on an exchange.- Parameters:
message
- message to publish.- Returns:
MockedSender.BasicPublisher
.
-
rpc
Send a RPC request with given message.- Parameters:
message
- Message to send.- Returns:
MockedSender.RpcPublisher
.
-