RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
mockRuntimeRepoIf.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_TEST_MOCKRUNTIMEREPOIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_TEST_MOCKRUNTIMEREPOIF_HPP
15
18
20
26class MockRuntimeRepoIf : virtual public RuntimeRepoIf {
27public:
29 // Setup the default behaviour to forward the calls to the fake repository.
30 ON_CALL(*this, DeleteDataPoint).WillByDefault([this](const DataPointPath& path) {
31 m_fakerepo.DeleteDataPoint(path);
32 });
33 ON_CALL(*this, GetDataPointType)
34 .WillByDefault([this](const DataPointPath& path) -> const std::type_info& {
35 return m_fakerepo.GetDataPointType(path);
36 });
37 ON_CALL(*this, GetDataPointSize).WillByDefault([this](const DataPointPath& path) {
38 return m_fakerepo.GetDataPointSize(path);
39 });
40 ON_CALL(*this, DataPointExists).WillByDefault([this](const DataPointPath& path) {
41 return m_fakerepo.DataPointExists(path);
42 });
43 ON_CALL(*this, GetChildren).WillByDefault([this](const DataPointPath& path) {
44 return m_fakerepo.GetChildren(path);
45 });
46 ON_CALL(*this, SendReadRequest).WillByDefault([this](const ReadRequest& request) {
47 return m_fakerepo.SendReadRequest(request);
48 });
49 ON_CALL(*this, SendWriteRequest).WillByDefault([this](const WriteRequest& request) {
50 return m_fakerepo.SendWriteRequest(request);
51 });
52 ON_CALL(*this, GetServerAlias)
53 .WillByDefault([this](const DataPointPath& path) -> std::string const {
54 return m_server_alias_map.at(path.ToString());
55 });
56 }
57
60 CreateDataPoint1,
61 (const DataPointPath&, const std::type_info&, const std::string& alias),
62 ());
63 MOCK_METHOD(void, DeleteDataPoint, (const DataPointPath&), (override));
64 MOCK_METHOD(const std::type_info&, GetDataPointType, (const DataPointPath&), (const override));
65 MOCK_METHOD(std::size_t, GetDataPointSize, (const DataPointPath&), (const override));
66 MOCK_METHOD(bool, DataPointExists, (const DataPointPath&), (const override));
67 MOCK_METHOD((std::pair<PathList, PathList>),
69 (const DataPointPath&),
70 (const override));
71 MOCK_METHOD(Response, SendReadRequest, (const ReadRequest&), (const override));
73
74 MOCK_METHOD(std::string, GetServerAlias, (const DataPointPath&), (const override));
77
78 void CreateDataPoint(const DataPointPath& path, const std::type_info& type) override {
79 CreateDataPoint(path, type, "");
80 }
81
83 const std::type_info& type,
84 const std::string& alias) override {
85 m_server_alias_map[path.ToString()] = alias;
86 m_fakerepo.CreateDataPoint(path, type);
87 this->CreateDataPoint1(path, type, alias);
88 }
89
90private:
91 FakeRepositoryIf m_fakerepo;
92 std::map<std::string, std::string> m_server_alias_map;
93};
94
95} // namespace rtctk::componentFramework::test
96
97#endif // RTCTK_COMPONENTFRAMEWORK_TEST_MOCKRUNTIMEREPOIF_HPP
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
const std::string & ToString() const noexcept
Get string representing the DataPointPath.
Definition: dataPointPath.hpp:423
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:49
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:122
virtual const std::type_info & GetDataPointType(const DataPointPath &path) const =0
Fetches the type of the datapoint.
virtual size_t GetDataPointSize(const DataPointPath &path) const =0
Fetches the size of the datapoint's data.
virtual std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const =0
Queries the datapoints and child paths for a given path.
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
virtual bool DataPointExists(const DataPointPath &path) const =0
Checks for the existence of a datapoint in the repository.
virtual Response SendWriteRequest(const WriteRequest &request)=0
Sends a request to write data to the repository.
virtual Response SendReadRequest(const ReadRequest &request) const =0
Sends a request to read data from the repository.
A request object to pass information about datapoints to subscribe to.
Definition: repositorySubscriberIf.hpp:37
A request object to pass information about datapoints to unsubscribe from.
Definition: repositorySubscriberIf.hpp:143
virtual RepositoryIf::Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const =0
This is called to asynchronously send a request to unsubscribe from various notifications.
virtual RepositoryIf::Response SendSubscribeRequest(const SubscribeRequest &request) const =0
This is called to asynchronously send a subscription request for datapoints.
Base interface for all Runtime Configuration Repository adapters.
Definition: runtimeRepoIf.hpp:28
virtual std::string GetServerAlias(const DataPointPath &path) const =0
Fetches the server alias for a specific datapoint.
Implementation of an in-memory fake repository for testing.
Definition: fakeRepositoryIf.hpp:31
Response SendReadRequest(const ReadRequest &) const override
Sends a request to read data from the repository.
Definition: fakeRepositoryIf.cpp:99
const std::type_info & GetDataPointType(const DataPointPath &) const override
Fetches the type of the datapoint.
Definition: fakeRepositoryIf.cpp:41
Response SendWriteRequest(const WriteRequest &) override
Sends a request to write data to the repository.
Definition: fakeRepositoryIf.cpp:103
std::size_t GetDataPointSize(const DataPointPath &) const override
Fetches the size of the datapoint's data.
Definition: fakeRepositoryIf.cpp:50
bool DataPointExists(const DataPointPath &) const override
Checks for the existence of a datapoint in the repository.
Definition: fakeRepositoryIf.cpp:60
void DeleteDataPoint(const DataPointPath &) override
Deletes a datapoint.
Definition: fakeRepositoryIf.cpp:28
void CreateDataPoint(const DataPointPath &, const std::type_info &) override
Creates a new datapoint in the repository with a specified type.
Definition: fakeRepositoryIf.cpp:19
std::pair< PathList, PathList > GetChildren(const DataPointPath &) const override
Queries the datapoints and child paths for a given path.
Definition: fakeRepositoryIf.cpp:66
A mock of RuntimeRepoIf.
Definition: mockRuntimeRepoIf.hpp:26
MOCK_METHOD(void, DeleteDataPoint,(const DataPointPath &),(override))
MOCK_METHOD(Response, SendSubscribeRequest,(const SubscribeRequest &),(const override))
MOCK_METHOD(const std::type_info &, GetDataPointType,(const DataPointPath &),(const override))
void CreateDataPoint(const DataPointPath &path, const std::type_info &type) override
Creates a new datapoint in the repository with a specified type.
Definition: mockRuntimeRepoIf.hpp:78
MOCK_METHOD(void, CreateDataPoint1,(const DataPointPath &, const std::type_info &, const std::string &alias),())
void CreateDataPoint(const DataPointPath &path, const std::type_info &type, const std::string &alias) override
Creates a new datapoint in the repository with a specified type on a particular external Redis server...
Definition: mockRuntimeRepoIf.hpp:82
MOCK_METHOD(std::string, GetServerAlias,(const DataPointPath &),(const override))
MOCK_METHOD(Response, SendReadRequest,(const ReadRequest &),(const override))
MOCK_METHOD((std::pair< PathList, PathList >), GetChildren,(const DataPointPath &),(const override))
MOCK_METHOD(Response, SendUnsubscribeRequest,(const UnsubscribeRequest &),(const override))
MOCK_METHOD(std::size_t, GetDataPointSize,(const DataPointPath &),(const override))
MOCK_METHOD(bool, DataPointExists,(const DataPointPath &),(const override))
MOCK_METHOD(Response, SendWriteRequest,(const WriteRequest &),(override))
MockRuntimeRepoIf()
Definition: mockRuntimeRepoIf.hpp:28
Header file for an in-memory fake RepositoryIf.
Definition: fakeClock.cpp:15
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.