14#include <gmock/gmock.h>
15#include <gtest/gtest.h>
28using ::testing::InSequence;
29using ::testing::NiceMock;
30using ::testing::Return;
31using ::testing::Sequence;
59 auto lock = std::scoped_lock(callback_lock);
67 auto lock = std::scoped_lock(callback_lock);
74 std::mutex callback_lock;
84 std::unique_ptr<EventPublisherIf>
MakePublisher(
const std::string& topic)
override {
86 return std::unique_ptr<MockEventPublisher>(
pub.at(topic));
89 std::unique_ptr<EventSubscriberIf>
MakeSubscriber(
const std::string& topic)
override {
91 return std::unique_ptr<MockEventSubscriber>(
sub.at(topic));
94 std::map<std::string, MockEventPublisher*>
pub;
95 std::map<std::string, MockEventSubscriber*>
sub;
104 es = std::make_shared<MockEventService>();
117 std::shared_ptr<MockEventService>
es;
Definition helpers.hpp:75
void Publish(const JsonPayload &sample) override
Publishes a JSON object.
Definition helpers.hpp:46
friend MockEventService
Definition helpers.hpp:77
Definition helpers.hpp:113
std::unique_ptr< EventPublisherIf > MakePublisher(const std::string &topic) override
Creates a new publisher for a specified topic.
Definition helpers.hpp:84
std::map< std::string, MockEventPublisher * > pub
Definition helpers.hpp:127
MockEventService()=default
std::map< std::string, MockEventSubscriber * > sub
Definition helpers.hpp:128
std::unique_ptr< EventSubscriberIf > MakeSubscriber(const std::string &topic) override
Creates a new subscriber for a specified topic.
Definition helpers.hpp:89
Definition helpers.hpp:87
void Subscribe(std::function< void(const JsonPayload &)> cb) override
Subscribes to a specified topic.
Definition helpers.hpp:58
MOCK_METHOD(void, SubscribeMock,(std::function< void(const JsonPayload &)>),())
MOCK_METHOD(void, Unsubscribe,(),(override))
std::function< void(const JsonPayload &)> GetCallback()
Definition helpers.hpp:66
friend MockEventService
Definition helpers.hpp:89
Component metrics interface.
Definition componentMetricsIf.hpp:163
Interface class for publishing JSON events.
Definition eventServiceIf.hpp:51
Interface class for providing pub/sub facilities for JSON events.
Definition eventServiceIf.hpp:28
Interface class for subscribing to JSON events.
Definition eventServiceIf.hpp:67
virtual void Unsubscribe()=0
Unsubscribes from a specified topic.
Base interface for all OLDB adapters.
Definition oldbIf.hpp:24
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:220
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:26
Container class that holds services of any type.
Definition serviceContainer.hpp:38
Header file for ComponentMetricsIf.
Low-level interface of the event service.
Declaration of helper mock class for ComponentMetricsIf.
Header file providing a FakeOldbIf.
Header file providing a FakeRuntimeRepoIf.
Definition fakeClock.cpp:14
Definition commandReplier.cpp:21
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:24
ACTION(Throw)
Definition helpers.hpp:120
A container that can hold any type of service.
Definition helpers.hpp:131
std::shared_ptr< MockEventService > es
Definition helpers.hpp:150
ServiceContainer & operator*()
Definition helpers.hpp:108
FakeServices()
Definition helpers.hpp:99
MockEventService & Es()
Definition helpers.hpp:112
ServiceContainer services
Definition helpers.hpp:149