15#include <gmock/gmock.h>
16#include <gtest/gtest.h>
29using ::testing::InSequence;
30using ::testing::NiceMock;
31using ::testing::Return;
32using ::testing::Sequence;
60 auto lock = std::scoped_lock(callback_lock);
68 auto lock = std::scoped_lock(callback_lock);
75 std::mutex callback_lock;
85 std::unique_ptr<EventPublisherIf>
MakePublisher(
const std::string& topic)
override {
87 return std::unique_ptr<MockEventPublisher>(
pub.at(topic));
90 std::unique_ptr<EventSubscriberIf>
MakeSubscriber(
const std::string& topic)
override {
92 return std::unique_ptr<MockEventSubscriber>(
sub.at(topic));
95 std::map<std::string, MockEventPublisher*>
pub;
96 std::map<std::string, MockEventSubscriber*>
sub;
105 es = std::make_shared<MockEventService>();
118 std::shared_ptr<MockEventService>
es;
Definition helpers.hpp:76
void Publish(const JsonPayload &sample) override
Publishes a JSON object.
Definition helpers.hpp:47
friend MockEventService
Definition helpers.hpp:78
Definition helpers.hpp:114
std::unique_ptr< EventPublisherIf > MakePublisher(const std::string &topic) override
Creates a new publisher for a specified topic.
Definition helpers.hpp:85
std::map< std::string, MockEventPublisher * > pub
Definition helpers.hpp:128
MockEventService()=default
std::map< std::string, MockEventSubscriber * > sub
Definition helpers.hpp:129
std::unique_ptr< EventSubscriberIf > MakeSubscriber(const std::string &topic) override
Creates a new subscriber for a specified topic.
Definition helpers.hpp:90
Definition helpers.hpp:88
void Subscribe(std::function< void(const JsonPayload &)> cb) override
Subscribes to a specified topic.
Definition helpers.hpp:59
MOCK_METHOD(void, SubscribeMock,(std::function< void(const JsonPayload &)>),())
MOCK_METHOD(void, Unsubscribe,(),(override))
std::function< void(const JsonPayload &)> GetCallback()
Definition helpers.hpp:67
friend MockEventService
Definition helpers.hpp:90
Component metrics interface.
Definition componentMetricsIf.hpp:164
Interface class for publishing JSON events.
Definition eventServiceIf.hpp:52
Interface class for providing pub/sub facilities for JSON events.
Definition eventServiceIf.hpp:29
Interface class for subscribing to JSON events.
Definition eventServiceIf.hpp:68
virtual void Unsubscribe()=0
Unsubscribes from a specified topic.
Base interface for all OLDB adapters.
Definition oldbIf.hpp:25
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:213
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:27
Container class that holds services of any type.
Definition serviceContainer.hpp:39
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:15
Definition commandReplier.cpp:22
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:25
ACTION(Throw)
Definition helpers.hpp:121
A container that can hold any type of service.
Definition helpers.hpp:132
std::shared_ptr< MockEventService > es
Definition helpers.hpp:151
ServiceContainer & operator*()
Definition helpers.hpp:109
FakeServices()
Definition helpers.hpp:100
MockEventService & Es()
Definition helpers.hpp:113
ServiceContainer services
Definition helpers.hpp:150