RMQ - RabbitMQ C++ Library
rmqtestmocks_mockconsumer.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_MOCKCONSUMER
17#define INCLUDED_RMQTESTMOCKS_MOCKCONSUMER
18
19#include <rmqa_consumer.h>
20#include <rmqp_consumer.h>
21#include <rmqt_future.h>
22#include <rmqt_message.h>
23
24#include <gmock/gmock.h>
25
26#include <bsl_memory.h>
27#include <bsls_timeinterval.h>
28
29namespace BloombergLP {
30namespace rmqtestmocks {
31
34
36 public:
37 // CREATORS
39 ~MockConsumer() BSLS_KEYWORD_OVERRIDE;
40
41 bsl::shared_ptr<rmqa::Consumer> consumer();
42
44 static rmqt::Result<rmqp::Consumer> timeout();
45 static rmqt::Result<rmqp::Consumer> error();
46
47 rmqt::Future<rmqp::Consumer> successAsync();
48 static rmqt::Future<rmqp::Consumer> timeoutAsync();
49 static rmqt::Future<rmqp::Consumer> errorAsync();
50
51 MOCK_METHOD0(cancel, rmqt::Future<>());
52 MOCK_METHOD0(drain, rmqt::Future<>());
53 MOCK_METHOD1(cancelAndDrain, rmqt::Result<>(const bsls::TimeInterval&));
54 MOCK_METHOD2(updateTopology,
56 const bsls::TimeInterval&));
57 MOCK_METHOD1(updateTopologyAsync,
59
60 private:
61 MockConsumer(const MockConsumer&) BSLS_KEYWORD_DELETED;
62 MockConsumer& operator=(const MockConsumer&) BSLS_KEYWORD_DELETED;
63
64}; // class MockConsumer
65
66} // namespace rmqtestmocks
67} // namespace BloombergLP
68
69#endif // ! INCLUDED_RMQTESTMOCKS_MOCKCONSUMER
Provide a RabbitMQ Async Consumer API.
Definition: rmqp_consumer.h:38
virtual rmqt::Future updateTopologyAsync(const rmqt::TopologyUpdate &topologyUpdate)=0
Updates topology.
virtual rmqt::Future drain()=0
Can only be called (successfully) once the Consumer has been cancelled, returns a future which resolv...
virtual rmqt::Future cancel()=0
Cancels the consumer, stops new messages flowing in.
virtual rmqt::Result cancelAndDrain(const bsls::TimeInterval &timeout)=0
Tells the broker to stop delivering messages to this consumer.
An async-style Future/Promise object.
Definition: rmqt_future.h:108
A result of an operation.
Definition: rmqt_result.h:37
Definition: rmqt_topologyupdate.h:33
Mocks rmqp::Consumer and/or rmqa::Consumer.
Definition: rmqtestmocks_mockconsumer.h:35