RMQ - RabbitMQ C++ Library
rmqtestmocks_mockproducer.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef INCLUDED_RMQTESTMOCKS_MOCKPRODUCER
17#define INCLUDED_RMQTESTMOCKS_MOCKPRODUCER
18
19#include <rmqa_producer.h>
20#include <rmqp_messagetransformer.h>
21#include <rmqp_producer.h>
22#include <rmqt_future.h>
23#include <rmqt_message.h>
24
25#include <gmock/gmock.h>
26
27#include <bsl_memory.h>
28#include <bsl_string.h>
29
30namespace BloombergLP {
31namespace rmqtestmocks {
32
35
37 public:
38 // CREATORS
40 ~MockProducer() BSLS_KEYWORD_OVERRIDE;
41
42 bsl::shared_ptr<rmqa::Producer> producer();
43
45 static rmqt::Result<rmqp::Producer> timeout();
46 static rmqt::Result<rmqp::Producer> error();
47
48 rmqt::Future<rmqp::Producer> successAsync();
49 static rmqt::Future<rmqp::Producer> timeoutAsync();
50 static rmqt::Future<rmqp::Producer> errorAsync();
51
52 MOCK_METHOD1(
54 void(const bsl::shared_ptr<rmqp::MessageTransformer>& transformer));
55
56 MOCK_METHOD4(
57 send,
59 const rmqt::Message& message,
60 const bsl::string& routingKey,
61 const rmqp::Producer::ConfirmationCallback& confirmCallback,
62 const bsls::TimeInterval& timeout));
63
64 MOCK_METHOD5(
65 send,
67 const rmqt::Message& message,
68 const bsl::string& routingKey,
69 rmqt::Mandatory::Value mandatory,
70 const rmqp::Producer::ConfirmationCallback& confirmCallback,
71 const bsls::TimeInterval& timeout));
72
73 MOCK_METHOD3(
74 trySend,
76 const rmqt::Message& message,
77 const bsl::string& routingKey,
78 const rmqp::Producer::ConfirmationCallback& confirmCallback));
79
80 MOCK_METHOD1(waitForConfirms, rmqt::Result<>(const bsls::TimeInterval&));
81
82 MOCK_METHOD2(updateTopology,
84 const bsls::TimeInterval&));
85 MOCK_METHOD1(updateTopologyAsync,
87
88 private:
89 MockProducer(const MockProducer&) BSLS_KEYWORD_DELETED;
90 MockProducer& operator=(const MockProducer&) BSLS_KEYWORD_DELETED;
91
92}; // class MockProducer
93
94} // namespace rmqtestmocks
95} // namespace BloombergLP
96
97#endif // ! INCLUDED_RMQTESTMOCKS_MOCKPRODUCER
RabbitMQ Producer API for publishing to a specific Exchange.
Definition: rmqp_producer.h:46
virtual SendStatus send(const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout)=0
Send a message with the given routingKey to the exchange targeted by the producer.
virtual rmqt::Result waitForConfirms(const bsls::TimeInterval &timeout)=0
Wait for all outstanding publisher confirms to arrive.
virtual void addTransformer(const bsl::shared_ptr< rmqp::MessageTransformer > &transformer)=0
Adds a transformation function to be run on all messages.
bsl::function< void(const rmqt::Message &, const bsl::string &routingKey, const rmqt::ConfirmResponse &)> ConfirmationCallback
Invoked on receipt of message confirmation.
Definition: rmqp_producer.h:71
virtual SendStatus trySend(const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback)=0
Send a message with the given routingKey to the exchange targeted by the producer.
Definition: rmqa_producer.cpp:55
SendStatus
Possible results of rmqp::Producer::send.
Definition: rmqp_producer.h:50
virtual rmqt::Future updateTopologyAsync(const rmqt::TopologyUpdate &topologyUpdate)=0
Updates topology.
An async-style Future/Promise object.
Definition: rmqt_future.h:108
An AMQP content message.
Definition: rmqt_message.h:43
A result of an operation.
Definition: rmqt_result.h:37
Definition: rmqt_topologyupdate.h:33
Mocks rmqp::Producer and/or rmqa::Producer.
Definition: rmqtestmocks_mockproducer.h:36