1 /*
2  * Copyright (c) 2015, 2021, 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 also distributed 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 included with MySQL.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License, version 2.0, for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23  * 02110-1301  USA
24  */
25 
26 
27 #include "ngs/capabilities/configurator.h"
28 #include "ngs/capabilities/handler.h"
29 
30 namespace ngs
31 {
32 
33 namespace test
34 {
35 
36 
37 class Mock_capabilities_configurator : public Capabilities_configurator
38 {
39 public:
Mock_capabilities_configurator()40   Mock_capabilities_configurator() : Capabilities_configurator(std::vector<Capability_handler_ptr>())
41   {}
42 
43   MOCK_METHOD0(get, ::Mysqlx::Connection::Capabilities *());
44 
45   MOCK_METHOD1(prepare_set, ngs::Error_code (const ::Mysqlx::Connection::Capabilities &capabilities));
46   MOCK_METHOD0(commit, void ());
47 };
48 
49 class Mock_capability_handler: public Capability_handler
50 {
51 public:
52   MOCK_CONST_METHOD0(name, const std::string ());
53   MOCK_CONST_METHOD0(is_supported, bool ());
54   MOCK_METHOD1(set, bool (const ::Mysqlx::Datatypes::Any &));
55 
56   // Workaround for GMOCK undefined behaviour with ResultHolder
57   MOCK_METHOD1(get_void, bool (::Mysqlx::Datatypes::Any &));
58   MOCK_METHOD0(commit_void, bool ());
59 
get(::Mysqlx::Datatypes::Any & any)60   void get(::Mysqlx::Datatypes::Any &any)
61   {
62     get_void(any);
63   }
64 
commit()65   void commit()
66   {
67     commit_void();
68   }
69 
70 };
71 
72 } // namespace test
73 
74 }  // namespace ngs
75