@@ -324,19 +324,28 @@ class MqttPublisherFbHelper : public DaqTestHelper
324324 expectedMsgsForMultimsg (const std::string& signalName0, const std::string& signalName1, std::vector<std::pair<T, uint64_t >> data)
325325 {
326326 std::vector<std::string> msgs;
327- const std::string PUBLISHER_SINGLE_MSG = " [{<placeholder_signal0> : <placeholder_value0>, \" timestamp\" : <placeholder_ts0>}, "
328- " {<placeholder_signal1> : <placeholder_value1>, \" timestamp\" : <placeholder_ts1>}]" ;
329-
327+ // const std::string PUBLISHER_SINGLE_MSG = "[{<placeholder_signal0> : <placeholder_value0>, \"timestamp\": <placeholder_ts0>}, "
328+ // "{<placeholder_signal1> : <placeholder_value1>, \"timestamp\": <placeholder_ts1>}]";
329+ const std::string PUBLISHER_SINGLE_MSG_FIRST = " {<placeholder_signal0> : <placeholder_value0>, \" timestamp\" : <placeholder_ts0>}" ;
330+ const std::string PUBLISHER_SINGLE_MSG_SECOND = " {<placeholder_signal1> : <placeholder_value1>, \" timestamp\" : <placeholder_ts1>}" ;
331+
332+ std::string tmpStr;
333+ tmpStr = replacePlaceholder (tmpStr, " <placeholder_first>" , PUBLISHER_SINGLE_MSG_FIRST);
334+ tmpStr = replacePlaceholder (tmpStr, " <placeholder_second>" , PUBLISHER_SINGLE_MSG_SECOND);
335+ const std::string PUBLISHER_SINGLE_MSG = std::move (tmpStr);
330336 std::vector<std::string> messages;
331337 {
332338 for (const auto & [value, ts] : data)
333339 {
334- auto msg = PUBLISHER_SINGLE_MSG ;
340+ auto msg = PUBLISHER_SINGLE_MSG_FIRST ;
335341 msg = replacePlaceholder (msg, " <placeholder_signal0>" , signalName0);
336- msg = replacePlaceholder (msg, " <placeholder_signal1>" , signalName1);
337342 msg = replacePlaceholder (msg, " <placeholder_value0>" , value);
338- msg = replacePlaceholder (msg, " <placeholder_value1>" , value);
339343 msg = replacePlaceholder (msg, " <placeholder_ts0>" , ts * 1000 );
344+ messages.push_back (std::move (msg));
345+
346+ msg = PUBLISHER_SINGLE_MSG_SECOND;
347+ msg = replacePlaceholder (msg, " <placeholder_signal1>" , signalName1);
348+ msg = replacePlaceholder (msg, " <placeholder_value1>" , value);
340349 msg = replacePlaceholder (msg, " <placeholder_ts1>" , ts * 1000 );
341350 messages.push_back (std::move (msg));
342351 }
@@ -405,12 +414,15 @@ class MqttPublisherFbHelper : public DaqTestHelper
405414 bool transfer (const std::string& topic,
406415 const std::vector<std::string>& messages,
407416 SignalHelper<T>& helper,
408- const std::vector<std::pair<T, uint64_t >>& data)
417+ const std::vector<std::pair<T, uint64_t >>& data, bool isMultimessage = false )
409418 {
410419 std::promise<bool > receivedPromise;
411420 auto receivedFuture = receivedPromise.get_future ();
412421 std::atomic<bool > done{false };
413- subscriber->expectMsgs (topic, messages, receivedPromise, done);
422+ if (isMultimessage)
423+ subscriber->expectMultiMsgs (topic, messages, receivedPromise, done);
424+ else
425+ subscriber->expectMsgs (topic, messages, receivedPromise, done);
414426
415427 helper::utils::Timer receiveTimer (5000 );
416428 bool ok = subscriber->subscribe (topic, 2 );
@@ -962,7 +974,7 @@ TEST_P(MqttPublisherFbPTest, TransferMultimessage)
962974 const auto data = help.generateTestData (sampleCnt);
963975 const std::vector<std::string> messages =
964976 expectedMsgsForMultimsg (help.signal0 .getGlobalId ().toStdString (), help.signal1 .getGlobalId ().toStdString (), data);
965- auto ok = transfer (topic, messages, help, data);
977+ auto ok = transfer (topic, messages, help, data, true );
966978 ASSERT_TRUE (ok);
967979 ASSERT_EQ (fb.getStatusContainer ().getStatus (" ComponentStatus" ),
968980 Enumeration (" ComponentStatusType" , " Ok" , daqInstance.getContext ().getTypeManager ()));
0 commit comments