@@ -42,19 +42,29 @@ void verifyXmlJsonResult(const std::string& json_content, size_t expected_record
4242
4343 if (add_attributes_as_fields) {
4444 string_result = current_record[" _topic" ].GetString ();
45- CHECK (string_result == " mytopic/segment" );
45+ CHECK (string_result == " mytopic/segment/ " + std::to_string (i) );
4646 auto array = current_record[" _topicSegments" ].GetArray ();
47- CHECK (array.Size () == 2 );
47+ CHECK (array.Size () == 3 );
4848 string_result = array[0 ].GetString ();
4949 CHECK (string_result == " mytopic" );
5050 string_result = array[1 ].GetString ();
5151 CHECK (string_result == " segment" );
52+ string_result = array[2 ].GetString ();
53+ CHECK (string_result == std::to_string (i));
5254 int_result = current_record[" _qos" ].GetInt64 ();
53- CHECK (int_result == 1 );
55+ CHECK (int_result == i );
5456 bool bool_result = current_record[" _isDuplicate" ].GetBool ();
55- CHECK_FALSE (bool_result);
57+ if (i == 0 ) {
58+ CHECK_FALSE (bool_result);
59+ } else {
60+ CHECK (bool_result);
61+ }
5662 bool_result = current_record[" _isRetained" ].GetBool ();
57- CHECK_FALSE (bool_result);
63+ if (i == 0 ) {
64+ CHECK_FALSE (bool_result);
65+ } else {
66+ CHECK (bool_result);
67+ }
5868 } else {
5969 CHECK_FALSE (current_record.HasMember (" _topic" ));
6070 CHECK_FALSE (current_record.HasMember (" _qos" ));
@@ -268,9 +278,10 @@ TEST_CASE_METHOD(ConsumeMqttTestFixture, "Read XML messages and write them to js
268278 const std::string payload = R"( <root><int_value>42</int_value><string_value>test</string_value></root>)" ;
269279 for (size_t i = 0 ; i < expected_record_count; ++i) {
270280 TestConsumeMQTTProcessor::SmartMessage message{std::unique_ptr<MQTTAsync_message, TestConsumeMQTTProcessor::MQTTMessageDeleter>(
271- new MQTTAsync_message{.struct_id = {' M' , ' Q' , ' T' , ' M' }, .struct_version = 1 , .payloadlen = gsl::narrow<int >(payload.size ()),
272- .payload = const_cast <char *>(payload.data ()), .qos = 1 , .retained = 0 , .dup = 0 , .msgid = 42 , .properties = {}}),
273- std::string{" mytopic/segment" }};
281+ new MQTTAsync_message{.struct_id = {' M' , ' Q' , ' T' , ' M' }, .struct_version = gsl::narrow<int >(i), .payloadlen = gsl::narrow<int >(payload.size ()),
282+ .payload = const_cast <char *>(payload.data ()), .qos = gsl::narrow<int >(i), .retained = gsl::narrow<int >(i), .dup = gsl::narrow<int >(i),
283+ .msgid = gsl::narrow<int >(i + 1 ), .properties = {}}),
284+ std::string{" mytopic/segment/" + std::to_string (i)}};
274285 consume_mqtt_processor_->enqueueReceivedMQTTMsg (std::move (message));
275286 }
276287 const auto trigger_results = test_controller_.trigger ();
@@ -359,7 +370,7 @@ TEST_CASE_METHOD(ConsumeMqttTestFixture, "Read MQTT message and write it to a fl
359370 }
360371}
361372
362- TEST_CASE_METHOD (ConsumeMqttTestFixture, " Test scheduling failure if non-existant recordset reader or writer is set" , " [consumeMQTTTest]" ) {
373+ TEST_CASE_METHOD (ConsumeMqttTestFixture, " Test scheduling failure if non-existent recordset reader or writer is set" , " [consumeMQTTTest]" ) {
363374 test_controller_.plan ->addController (" XMLReader" , " XMLReader" );
364375 test_controller_.plan ->addController (" JsonRecordSetWriter" , " JsonRecordSetWriter" );
365376 REQUIRE (consume_mqtt_processor_->setProperty (minifi::processors::AbstractMQTTProcessor::BrokerURI.name , " 127.0.0.1:1883" ));
0 commit comments