10#include <gmock/gmock.h>
11#include <gtest/gtest.h>
12#include <log4cplus/logger.h>
24using namespace ::testing;
33 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
34 auto reply_mock = std::make_shared<DaqReplyMock>();
35 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
36 auto reply_mock2 = std::make_shared<DaqReplyMock>();
38 EXPECT_CALL(*m_meta_rr_client, StartDaq(
"id"))
39 .WillOnce(Return(ByMove(reply_promise.get_future())));
40 EXPECT_CALL(*m_meta_rr_client2, StartDaq(
"id"))
41 .WillOnce(Return(ByMove(reply_promise2.get_future())));
43 boost::promise<std::shared_ptr<recif::RecStatus>> prim_promise_1;
44 boost::promise<std::shared_ptr<recif::RecStatus>> prim_promise_2;
45 auto prim_reply_mock_1 = std::make_shared<RecStatusMock>();
46 EXPECT_CALL(*m_prim_rr_client, RecStart(RecPropertyIdEq(
"id")))
47 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
48 EXPECT_CALL(*m_prim_rr_client2, RecStart(RecPropertyIdEq(
"id")))
49 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
52 boost::future<void> fut = op::InitiateOperation<op::StartAsync>(m_executor, MakeParams());
53 EXPECT_FALSE(fut.is_ready());
56 reply_promise.set_value(reply_mock);
57 reply_promise2.set_value(reply_mock2);
58 prim_promise_1.set_value(prim_reply_mock_1);
59 prim_promise_2.set_value(prim_reply_mock_1);
65 ASSERT_FALSE(fut.has_exception());
71 EXPECT_CALL(*m_meta_rr_client, StartDaq(_))
72 .WillOnce(Throw(std::runtime_error(
"Fake test failure")));
75 EXPECT_CALL(*m_meta_rr_client2, StartDaq(_)).Times(0);
78 boost::future<void> fut = op::InitiateOperation<op::StartAsync>(m_executor, MakeParams());
79 EXPECT_FALSE(fut.is_ready());
86 EXPECT_TRUE(fut.has_exception()) <<
"Expected future to contain exception";
87 EXPECT_THROW(fut.get(), std::exception) <<
"Expected exception to derive from std::exception";
92 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
93 auto reply_mock = std::make_shared<DaqReplyMock>();
94 EXPECT_CALL(*reply_mock, getMessage()).WillRepeatedly(Return(std::string(
"some message")));
96 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
97 auto reply_mock2 = std::make_shared<DaqReplyMock>();
98 EXPECT_CALL(*reply_mock2, getMessage()).WillRepeatedly(Return(std::string(
"some message")));
101 EXPECT_CALL(*m_meta_rr_client, StartDaq(_))
102 .WillOnce(Return(ByMove(reply_promise.get_future())));
104 EXPECT_CALL(*m_meta_rr_client2, StartDaq(_))
105 .WillOnce(Return(ByMove(reply_promise2.get_future())));
108 boost::future<void> fut = op::InitiateOperation<op::StartAsync>(m_executor, MakeParams());
109 EXPECT_FALSE(fut.is_ready());
112 reply_promise.set_exception(metadaqif::DaqException(
"foo",
"baz"));
113 reply_promise2.set_value(reply_mock2);
Exception thrown to carry reply errors.
Contains error related declarations for DAQ.
void MakeTestProgress(boost::asio::io_context &io_ctx, Future *fut=nullptr)
Test helper that progress the test by executing pending jobs and optionally wait for a future to be r...
Base fixture for async operation tests.
Contains declarations for the helper functions to initiate operations.
Mockup of metadaqif classes.
Contains declaration for the StartAsync operation.
Contains declaration for async operations shared base class.
TEST_F(TestAsyncOpStart, Start)
ASSERT_TRUE(std::holds_alternative< OlasReceiver >(spec.receivers[0]))
Defines shared test utilities.