1f77189f7SLei YU #include "utils.hpp"
2f77189f7SLei YU 
3f77189f7SLei YU #include <gmock/gmock.h>
4f77189f7SLei YU 
5f77189f7SLei YU namespace utils
6f77189f7SLei YU {
7f77189f7SLei YU 
8f77189f7SLei YU class MockedUtils : public UtilsInterface
9f77189f7SLei YU {
10f77189f7SLei YU   public:
11*047d9944SGeorge Liu     ~MockedUtils() override = default;
12f77189f7SLei YU 
13f77189f7SLei YU     MOCK_CONST_METHOD1(getPSUInventoryPath,
14374fae56SPatrick Williams                        std::vector<std::string>(sdbusplus::bus_t& bus));
15f77189f7SLei YU 
16f77189f7SLei YU     MOCK_CONST_METHOD3(getService,
17374fae56SPatrick Williams                        std::string(sdbusplus::bus_t& bus, const char* path,
18f77189f7SLei YU                                    const char* interface));
19f77189f7SLei YU 
20d0bbfa9eSLei YU     MOCK_CONST_METHOD3(getServices,
21374fae56SPatrick Williams                        std::vector<std::string>(sdbusplus::bus_t& bus,
22d0bbfa9eSLei YU                                                 const char* path,
23d0bbfa9eSLei YU                                                 const char* interface));
24d0bbfa9eSLei YU 
25f77189f7SLei YU     MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version));
26f77189f7SLei YU 
275f3584d4SLei YU     MOCK_CONST_METHOD1(getVersion,
285f3584d4SLei YU                        std::string(const std::string& psuInventoryPath));
295f3584d4SLei YU 
306520748dSLei YU     MOCK_CONST_METHOD1(getLatestVersion,
316520748dSLei YU                        std::string(const std::set<std::string>& versions));
326520748dSLei YU 
334b9ac392SLei YU     MOCK_CONST_METHOD2(isAssociated, bool(const std::string& psuInventoryPath,
344b9ac392SLei YU                                           const AssociationList& assocs));
354b9ac392SLei YU 
36f77189f7SLei YU     MOCK_CONST_METHOD5(getPropertyImpl,
37374fae56SPatrick Williams                        any(sdbusplus::bus_t& bus, const char* service,
38f77189f7SLei YU                            const char* path, const char* interface,
39f77189f7SLei YU                            const char* propertyName));
40f77189f7SLei YU };
41f77189f7SLei YU 
42c09155bbSLei YU static std::unique_ptr<MockedUtils> utils;
43ff83c2a0SLei YU inline const UtilsInterface& getUtils()
44f77189f7SLei YU {
45c09155bbSLei YU     if (!utils)
46c09155bbSLei YU     {
47c09155bbSLei YU         utils = std::make_unique<MockedUtils>();
48c09155bbSLei YU     }
49c09155bbSLei YU     return *utils;
50c09155bbSLei YU }
51c09155bbSLei YU 
52c09155bbSLei YU inline void freeUtils()
53c09155bbSLei YU {
54c09155bbSLei YU     utils.reset();
55f77189f7SLei YU }
56f77189f7SLei YU 
57f77189f7SLei YU } // namespace utils
58