| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef UNITTEST_GUNIT_XPLUGIN_XCL_MOCK_MESSAGE_HANDLER_H_ |
| 27 |
#define UNITTEST_GUNIT_XPLUGIN_XCL_MOCK_MESSAGE_HANDLER_H_ |
| 28 |
|
| 29 |
#include <gmock/gmock.h> |
| 30 |
#include <cstdint> |
| 31 |
#include <memory> |
| 32 |
#include <string> |
| 33 |
#include <utility> |
| 34 |
|
| 35 |
#include "plugin/x/client/mysqlxclient/xprotocol.h" |
| 36 |
|
| 37 |
namespace xcl { |
| 38 |
namespace test { |
| 39 |
namespace mock { |
| 40 |
|
| 41 |
class Message_handlers { |
| 42 |
public: |
| 43 |
XProtocol::Server_message_handler get_mock_lambda_received_message_handler() { |
| 44 |
return |
| 45 |
[this](XProtocol *protocol, const XProtocol::Server_message_type_id id, |
| 46 |
const XProtocol::Message &msg) -> Handler_result { |
| 47 |
return this->received_message_handler(protocol, id, msg); |
| 48 |
}; |
| 49 |
} |
| 50 |
|
| 51 |
XProtocol::Client_message_handler get_mock_lambda_send_message_handler() { |
| 52 |
return |
| 53 |
[this](XProtocol *protocol, const XProtocol::Client_message_type_id id, |
| 54 |
const XProtocol::Message &msg) -> Handler_result { |
| 55 |
return this->send_message_handler(protocol, id, msg); |
| 56 |
}; |
| 57 |
} |
| 58 |
|
| 59 |
XProtocol::Notice_handler get_mock_lambda_notice_handler() { |
| 60 |
return [this](XProtocol *protocol, const bool is_global, |
| 61 |
const Mysqlx::Notice::Frame::Type type, const char *payload, |
| 62 |
const uint32_t payload_size) -> Handler_result { |
| 63 |
return this->notice_handler(protocol, is_global, type, payload, |
| 64 |
payload_size); |
| 65 |
}; |
| 66 |
} |
| 67 |
|
| 68 |
public: |
| 69 |
MOCK_METHOD(Handler_result, received_message_handler, |
| 70 |
(XProtocol *, const XProtocol::Server_message_type_id, |
| 71 |
const XProtocol::Message &)); |
| 72 |
|
| 73 |
MOCK_METHOD(Handler_result, send_message_handler, |
| 74 |
(XProtocol *, const XProtocol::Client_message_type_id, |
| 75 |
const XProtocol::Message &)); |
| 76 |
|
| 77 |
MOCK_METHOD(Handler_result, notice_handler, |
| 78 |
(XProtocol *, const bool, const Mysqlx::Notice::Frame::Type, |
| 79 |
const char *, const uint32_t)); |
| 80 |
}; |
| 81 |
|
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
#endif |