10 #include <gmock/gmock.h>
11 #include <gtest/gtest.h>
12 #include <log4cplus/logger.h>
22 using namespace ::testing;
32 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
33 auto reply_mock = std::make_shared<DaqReplyMock>();
35 EXPECT_CALL(*m_meta_rr_client, AbortDaq(_))
36 .WillOnce(Return(ByMove(reply_promise.get_future())));
38 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
39 auto reply_mock2 = std::make_shared<DaqReplyMock>();
40 EXPECT_CALL(*m_meta_rr_client2, AbortDaq(_))
41 .WillOnce(Return(ByMove(reply_promise2.get_future())));
43 boost::promise<std::string> prim_promise_1;
44 boost::promise<std::string> prim_promise_2;
45 EXPECT_CALL(*m_prim_rr_client, RecAbort())
46 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
47 EXPECT_CALL(*m_prim_rr_client2, RecAbort())
48 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
51 auto fut = op::InitiateOperation<op::AbortAsync>(ErrorPolicy::Strict, MakeParams());
54 reply_promise.set_value(reply_mock);
55 reply_promise2.set_value(reply_mock);
56 prim_promise_1.set_value(
"OK");
57 prim_promise_2.set_value(
"OK");
62 ASSERT_TRUE(fut.is_ready());
63 ASSERT_FALSE(fut.has_exception()) <<
"Future has unexpected exception!";
67 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
68 auto reply_mock = std::make_shared<DaqReplyMock>();
70 EXPECT_CALL(*m_meta_rr_client, AbortDaq(_))
71 .WillOnce(Return(ByMove(reply_promise.get_future())));
73 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
74 auto reply_mock2 = std::make_shared<DaqReplyMock>();
75 EXPECT_CALL(*m_meta_rr_client2, AbortDaq(_))
76 .WillOnce(Return(ByMove(reply_promise2.get_future())));
78 boost::promise<std::string> prim_promise_1;
79 boost::promise<std::string> prim_promise_2;
81 EXPECT_CALL(*m_prim_rr_client, RecAbort())
82 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
83 EXPECT_CALL(*m_prim_rr_client2, RecAbort())
84 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
87 auto fut = op::InitiateOperation<op::AbortAsync>(ErrorPolicy::Strict, MakeParams());
90 reply_promise.set_value(reply_mock);
91 reply_promise2.set_exception(metadaqif::DaqException(m_id,
"message"));
92 prim_promise_1.set_value(
"OK");
93 prim_promise_2.set_value(
"OK");
98 ASSERT_TRUE(fut.is_ready());
103 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
104 auto reply_mock = std::make_shared<DaqReplyMock>();
106 EXPECT_CALL(*m_meta_rr_client, AbortDaq(_))
107 .WillOnce(Return(ByMove(reply_promise.get_future())));
109 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
110 auto reply_mock2 = std::make_shared<DaqReplyMock>();
111 EXPECT_CALL(*m_meta_rr_client2, AbortDaq(_))
112 .WillOnce(Return(ByMove(reply_promise2.get_future())));
114 boost::promise<std::string> prim_promise_1;
115 boost::promise<std::string> prim_promise_2;
117 EXPECT_CALL(*m_prim_rr_client, RecAbort())
118 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
119 EXPECT_CALL(*m_prim_rr_client2, RecAbort())
120 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
123 auto fut = op::InitiateOperation<op::AbortAsync>(ErrorPolicy::Strict, MakeParams());
126 reply_promise.set_value(reply_mock);
127 reply_promise2.set_value(reply_mock);
128 prim_promise_1.set_value(
"OK");
129 prim_promise_2.set_exception(metadaqif::DaqException(m_id,
"message"));
134 ASSERT_TRUE(fut.is_ready());
139 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
140 auto reply_mock = std::make_shared<DaqReplyMock>();
142 EXPECT_CALL(*m_meta_rr_client, AbortDaq(_))
143 .WillOnce(Return(ByMove(reply_promise.get_future())));
145 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
146 auto reply_mock2 = std::make_shared<DaqReplyMock>();
147 EXPECT_CALL(*m_meta_rr_client2, AbortDaq(_))
148 .WillOnce(Return(ByMove(reply_promise2.get_future())));
150 boost::promise<std::string> prim_promise_1;
151 boost::promise<std::string> prim_promise_2;
152 EXPECT_CALL(*m_prim_rr_client, RecAbort())
153 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
154 EXPECT_CALL(*m_prim_rr_client2, RecAbort())
155 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
161 reply_promise.set_value(reply_mock);
162 reply_promise2.set_exception(metadaqif::DaqException(m_id,
"message"));
163 prim_promise_1.set_value(
"OK");
164 prim_promise_2.set_value(
"OK");
169 ASSERT_TRUE(fut.is_ready());
170 EXPECT_FALSE(fut.has_exception());
174 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise;
175 auto reply_mock = std::make_shared<DaqReplyMock>();
177 EXPECT_CALL(*m_meta_rr_client, AbortDaq(_))
178 .WillOnce(Return(ByMove(reply_promise.get_future())));
180 boost::promise<std::shared_ptr<metadaqif::DaqReply>> reply_promise2;
181 auto reply_mock2 = std::make_shared<DaqReplyMock>();
182 EXPECT_CALL(*m_meta_rr_client2, AbortDaq(_))
183 .WillOnce(Return(ByMove(reply_promise2.get_future())));
185 boost::promise<std::string> prim_promise_1;
186 boost::promise<std::string> prim_promise_2;
187 EXPECT_CALL(*m_prim_rr_client, RecAbort())
188 .WillOnce(Return(ByMove(prim_promise_1.get_future())));
189 EXPECT_CALL(*m_prim_rr_client2, RecAbort())
190 .WillOnce(Return(ByMove(prim_promise_2.get_future())));
196 reply_promise.set_value(reply_mock);
197 reply_promise2.set_value(reply_mock);
198 prim_promise_1.set_value(
"OK");
199 prim_promise_2.set_exception(std::runtime_error(
"some error"));
204 ASSERT_TRUE(fut.is_ready());
205 EXPECT_FALSE(fut.has_exception());