Debian Codegraph @

unittest/gunit/xplugin/xcl/mock/message_handler.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2017, 2026, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License, version 2.0, for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 } // namespace mock
83 } // namespace test
84 } // namespace xcl
85
86 #endif // UNITTEST_GUNIT_XPLUGIN_XCL_MOCK_MESSAGE_HANDLER_H_