diff --git a/test_package/agent_adapter_test.cpp b/test_package/agent_adapter_test.cpp index d814470b5..2bb280d15 100644 --- a/test_package/agent_adapter_test.cpp +++ b/test_package/agent_adapter_test.cpp @@ -15,6 +15,10 @@ // limitations under the License. // + +/// @file +/// Tests for Agent-Adapter interactions + // Ensure that gtest is the first header otherwise Windows raises an error #include // Keep this comment to keep gtest.h above. (clang-format off/on is not working here!) @@ -173,6 +177,7 @@ class AgentAdapterTest : public testing::Test DevicePtr m_device; }; +/// @test Tests if the adapter can connect to the agent. TEST_F(AgentAdapterTest, should_connect_to_agent) { createAgent(); @@ -216,6 +221,7 @@ TEST_F(AgentAdapterTest, should_connect_to_agent) timeout.cancel(); } +/// @test Tests if the the agent can return current observations. TEST_F(AgentAdapterTest, should_get_current_from_agent) { createAgent(); @@ -253,6 +259,7 @@ TEST_F(AgentAdapterTest, should_get_current_from_agent) timeout.cancel(); } +/// @test Tests if the agent can return assets. TEST_F(AgentAdapterTest, should_get_assets_from_agent) { createAgent(); @@ -290,6 +297,7 @@ TEST_F(AgentAdapterTest, should_get_assets_from_agent) timeout.cancel(); } +/// @test Tests if the agent return a sample of observations. TEST_F(AgentAdapterTest, should_receive_sample) { createAgent(); @@ -347,6 +355,7 @@ TEST_F(AgentAdapterTest, should_receive_sample) timeout.cancel(); } +/// @test Tests if the agent reconnects to the adapter. TEST_F(AgentAdapterTest, should_reconnect) { createAgent(); @@ -415,6 +424,7 @@ TEST_F(AgentAdapterTest, should_reconnect) timeout.cancel(); } +/// @test Tests if the adapter can connect to an HTTP 1.0 agent. TEST_F(AgentAdapterTest, should_connect_with_http_10_agent) { createAgent(); @@ -472,6 +482,7 @@ TEST_F(AgentAdapterTest, should_connect_with_http_10_agent) timeout.cancel(); } +/// @test Tests if the instance ID gets checked after recovering from disconnect. TEST_F(AgentAdapterTest, should_check_instance_id_on_recovery) { createAgent(); @@ -565,6 +576,7 @@ TEST_F(AgentAdapterTest, should_check_instance_id_on_recovery) timeout.cancel(); } +/// @test Tests if the agent can map device names and device UUIDs TEST_F(AgentAdapterTest, should_map_device_name_and_uuid) { createAgent(); @@ -595,6 +607,7 @@ TEST_F(AgentAdapterTest, should_map_device_name_and_uuid) ASSERT_EQ("NewMachine", contract->m_deviceName); } +/// @test Tests if the polling is used when configured. TEST_F(AgentAdapterTest, should_use_polling_when_option_is_set) { createAgent(); @@ -673,6 +686,7 @@ const string KeyFile {TEST_RESOURCE_DIR "/user.key"}; const string DhFile {TEST_RESOURCE_DIR "/dh2048.pem"}; const string RootCertFile(TEST_RESOURCE_DIR "/rootca.crt"); +/// @test Tests if the adapter connects to an agent using TLS. TEST_F(AgentAdapterTest, should_connect_to_tls_agent) { using namespace mtconnect::configuration; @@ -718,6 +732,7 @@ TEST_F(AgentAdapterTest, should_connect_to_tls_agent) timeout.cancel(); } +/// @test Tests if the agent creates devices when specified. TEST_F(AgentAdapterTest, should_create_device_when_option_supplied) { createAgent({}, "/samples/solid_model.xml"); diff --git a/test_package/agent_device_test.cpp b/test_package/agent_device_test.cpp index 080724c0f..15b83b84f 100644 --- a/test_package/agent_device_test.cpp +++ b/test_package/agent_device_test.cpp @@ -121,6 +121,7 @@ class AgentDeviceTest : public testing::Test string m_line; }; +/// @test Tests if the agent device gets created. TEST_F(AgentDeviceTest, AgentDeviceCreation) { ASSERT_NE(nullptr, m_agentDevice); @@ -128,6 +129,7 @@ TEST_F(AgentDeviceTest, AgentDeviceCreation) ASSERT_EQ("Agent", m_agentDevice->getName().str()); } +/// @test Tests if the agent implementes the minimal required data items. TEST_F(AgentDeviceTest, VerifyRequiredDataItems) { ASSERT_NE(nullptr, m_agentDevice); @@ -148,6 +150,7 @@ TEST_F(AgentDeviceTest, VerifyRequiredDataItems) ASSERT_EQ("DEVICE_CHANGED", changed->getType()); } +/// @test Tests whether daat points get added to the buffer TEST_F(AgentDeviceTest, DeviceAddedItemsInBuffer) { auto agent = m_agentTestHelper->getAgent(); @@ -180,6 +183,7 @@ TEST_F(AgentDeviceTest, DeviceAddedItemsInBuffer) #define ID_PREFIX "_d0c33d4315" +/// @test Tests if adapter data items can be found on a probe. TEST_F(AgentDeviceTest, AdapterAddedProbeTest) { m_port = 21788; @@ -203,6 +207,7 @@ TEST_F(AgentDeviceTest, AdapterAddedProbeTest) } } +/// @test Tests if the adapter can be accessed without the IP address. TEST_F(AgentDeviceTest, adapter_component_with_ip_address_suppressed) { m_port = 21788; @@ -222,6 +227,7 @@ TEST_F(AgentDeviceTest, adapter_component_with_ip_address_suppressed) #define AGENT_DEVICE_DEVICE_STREAM AGENT_DEVICE_STREAM "/m:ComponentStream[@component='Agent']" #define AGENT_DEVICE_ADAPTER_STREAM AGENT_DEVICE_STREAM "/m:ComponentStream[@component='Adapter']" +/// @test Tests if the current observations can get updated through an adapter. TEST_F(AgentDeviceTest, AdapterAddedCurrentTest) { { @@ -245,6 +251,7 @@ TEST_F(AgentDeviceTest, AdapterAddedCurrentTest) } } +/// @test Tests if the adapter reports its connection to the agent. TEST_F(AgentDeviceTest, TestAdapterConnectionStatus) { srand(int32_t(chrono::system_clock::now().time_since_epoch().count())); @@ -303,6 +310,7 @@ TEST_F(AgentDeviceTest, TestAdapterConnectionStatus) } } +/// @test Tests if the UUID set in configuration is reported in the agent XML. TEST_F(AgentDeviceTest, verify_uuid_can_be_set_in_configuration) { m_agentTestHelper = make_unique(); diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index 747757694..d3344c985 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -87,6 +87,7 @@ class AgentTest : public testing::Test std::chrono::milliseconds m_delay {}; }; +/// @test Tests if the agent can be constructed with parameters. TEST_F(AgentTest, Constructor) { using namespace configuration; @@ -108,6 +109,7 @@ TEST_F(AgentTest, Constructor) ASSERT_NO_THROW(agent->initialize(context)); } +/// @test Tests if a agent returns a probe request. TEST_F(AgentTest, Probe) { { @@ -131,6 +133,7 @@ TEST_F(AgentTest, Probe) } } +/// @test Tests if the agent properly fails when two devices have the same UUID. TEST_F(AgentTest, FailWithDuplicateDeviceUUID) { using namespace configuration; @@ -144,6 +147,7 @@ TEST_F(AgentTest, FailWithDuplicateDeviceUUID) ASSERT_THROW(agent->initialize(context), std::runtime_error); } +/// @test Tests if the agent returns the correct message when it is probed for a device that doesnt exist. TEST_F(AgentTest, BadDevices) { { @@ -155,6 +159,7 @@ TEST_F(AgentTest, BadDevices) } } +/// @test Tests if the agent returns the correct message when an invalid Xpath is recieved. TEST_F(AgentTest, BadXPath) { { @@ -183,6 +188,7 @@ TEST_F(AgentTest, BadXPath) } } +/// @test Tests if the agent can parse URL paths. TEST_F(AgentTest, GoodPath) { { @@ -205,6 +211,7 @@ TEST_F(AgentTest, GoodPath) } } +/// @test Tests if the agent returns the correct message when an invalid URL path is recieved. TEST_F(AgentTest, BadPath) { using namespace rest_sink; @@ -234,6 +241,7 @@ TEST_F(AgentTest, BadPath) } } +/// @test Tests if the agent returns the correct observation within the buffer at any index. TEST_F(AgentTest, CurrentAt) { QueryMap query; @@ -303,6 +311,7 @@ TEST_F(AgentTest, CurrentAt) } } +/// @test Tests if the agent returns the correct observation within the buffer at any index. TEST_F(AgentTest, CurrentAt64) { QueryMap query; @@ -335,6 +344,7 @@ TEST_F(AgentTest, CurrentAt64) } } +/// @test Tests if the agent fails correctly when trying to access observations out of range of the buffer. TEST_F(AgentTest, CurrentAtOutOfRange) { QueryMap query; @@ -373,8 +383,10 @@ TEST_F(AgentTest, CurrentAtOutOfRange) } } +/// @test Tests adding an adapter to the agent. TEST_F(AgentTest, AddAdapter) { addAdapter(); } +/// @test Tests downloading a file from the agent TEST_F(AgentTest, FileDownload) { QueryMap query; @@ -394,6 +406,7 @@ TEST_F(AgentTest, FileDownload) string::npos); } +/// @test Tests if the agent returns the correct response when an invalid download request is recieved TEST_F(AgentTest, FailedFileDownload) { QueryMap query; @@ -412,6 +425,7 @@ TEST_F(AgentTest, FailedFileDownload) } } +/// @test Tests if composition data items are represented correctly in /current. TEST_F(AgentTest, Composition) { auto agent = m_agentTestHelper->m_agent.get(); @@ -437,6 +451,7 @@ TEST_F(AgentTest, Composition) } } +/// @test Tests if the agent returns the correct errors when invalid counts are used as parameters. TEST_F(AgentTest, BadCount) { auto &circ = m_agentTestHelper->getAgent()->getCircularBuffer(); @@ -494,6 +509,7 @@ TEST_F(AgentTest, BadCount) } } +/// @test Tests if the agent correctly communicates with the adapter. TEST_F(AgentTest, Adapter) { addAdapter(); @@ -524,6 +540,7 @@ TEST_F(AgentTest, Adapter) } } +/// @test Tests if the sequence number correctly points to the next data item. TEST_F(AgentTest, SampleAtNextSeq) { QueryMap query; @@ -548,6 +565,7 @@ TEST_F(AgentTest, SampleAtNextSeq) } } +/// @test Tests if the agent returns the correct amount of observations specified by the count parameter. TEST_F(AgentTest, SampleCount) { QueryMap query; @@ -584,6 +602,7 @@ TEST_F(AgentTest, SampleCount) } } +/// @test Tests if the agent returns the correct amount of observations starting from the back specified by the count parameter when using a negative number. TEST_F(AgentTest, SampleLastCount) { QueryMap query; @@ -620,6 +639,7 @@ TEST_F(AgentTest, SampleLastCount) } } +/// @test Tests if the correct parameters are retruned for each sample. TEST_F(AgentTest, SampleToParameter) { QueryMap query; @@ -683,6 +703,7 @@ TEST_F(AgentTest, SampleToParameter) // to > from } +/// @test Tests the empty stream response. TEST_F(AgentTest, EmptyStream) { { @@ -705,6 +726,7 @@ TEST_F(AgentTest, EmptyStream) } } +/// @test Tests if observations are added to the buffer correctly. TEST_F(AgentTest, AddToBuffer) { auto agent = m_agentTestHelper->m_agent.get(); @@ -741,6 +763,7 @@ TEST_F(AgentTest, AddToBuffer) } } +/// @test Tests if sequence numbers restart after overflow. TEST_F(AgentTest, SequenceNumberRollover) { #ifndef WIN32 @@ -797,6 +820,7 @@ TEST_F(AgentTest, SequenceNumberRollover) #endif } +/// @test Tests if sequence numbers do no duplicate. TEST_F(AgentTest, DuplicateCheck) { addAdapter(); @@ -824,6 +848,7 @@ TEST_F(AgentTest, DuplicateCheck) } } +/// @test Tests if the agent allows duplicate sequence numbers after disconnect. TEST_F(AgentTest, DuplicateCheckAfterDisconnect) { addAdapter({{configuration::FilterDuplicates, true}}); @@ -863,6 +888,7 @@ TEST_F(AgentTest, DuplicateCheckAfterDisconnect) } } +/// @test Tests if the agent automatically updates the availability data item. TEST_F(AgentTest, AutoAvailable) { addAdapter({{configuration::AutoAvailable, true}}); @@ -906,6 +932,7 @@ TEST_F(AgentTest, AutoAvailable) } } +/// @test Tests if the agent handles multiple disconnects properly. TEST_F(AgentTest, MultipleDisconnect) { addAdapter(); @@ -976,6 +1003,7 @@ TEST_F(AgentTest, MultipleDisconnect) } } +/// @test Tests if the agent ignores timestamps when set in the configuration. TEST_F(AgentTest, IgnoreTimestamps) { addAdapter(); @@ -999,6 +1027,7 @@ TEST_F(AgentTest, IgnoreTimestamps) } } +/// @test Tests if the data items are initially set to unavailable. TEST_F(AgentTest, InitialTimeSeriesValues) { addAdapter(); @@ -1010,6 +1039,7 @@ TEST_F(AgentTest, InitialTimeSeriesValues) } } +/// @test Tests the calibration on data items on the agent. TEST_F(AgentTest, DynamicCalibration) { addAdapter({{configuration::ConversionRequired, true}}); @@ -1052,6 +1082,7 @@ TEST_F(AgentTest, DynamicCalibration) } } +/// @test Tests value filtering on the agent. TEST_F(AgentTest, FilterValues13) { m_agentTestHelper->createAgent("/samples/filter_example_1.3.xml", 8, 4, "1.5", 25); @@ -1091,6 +1122,7 @@ TEST_F(AgentTest, FilterValues13) } } +/// @test Tests value filtering on the agent. TEST_F(AgentTest, FilterValues) { m_agentTestHelper->createAgent("/samples/filter_example_1.3.xml", 8, 4, "1.5", 25); @@ -1155,6 +1187,7 @@ TEST_F(AgentTest, FilterValues) } } +/// @test Tests the period filter with the ignore timestamps configuration set. TEST_F(AgentTest, TestPeriodFilterWithIgnoreTimestamps) { // Test period filter with ignore timestamps @@ -1186,6 +1219,7 @@ TEST_F(AgentTest, TestPeriodFilterWithIgnoreTimestamps) } } +/// @test Tests the period filter with the relative timestamps configuration set. TEST_F(AgentTest, TestPeriodFilterWithRelativeTime) { // Test period filter with relative time @@ -1216,6 +1250,7 @@ TEST_F(AgentTest, TestPeriodFilterWithRelativeTime) } } +/// @test Tests the "resetTriggered" flag. TEST_F(AgentTest, ResetTriggered) { addAdapter(); @@ -1239,6 +1274,7 @@ TEST_F(AgentTest, ResetTriggered) } } +/// @test Tests references in the device.xml file. TEST_F(AgentTest, References) { using namespace device_model; @@ -1301,6 +1337,7 @@ TEST_F(AgentTest, References) } } +/// @test Tests discrete items in the device.xml file. TEST_F(AgentTest, Discrete) { m_agentTestHelper->createAgent("/samples/discrete_example.xml"); @@ -1345,6 +1382,7 @@ TEST_F(AgentTest, Discrete) // ------------------------------ +/// @test Tests if the agent reports all string values in uppercase when set in the configuration. TEST_F(AgentTest, UpcaseValues) { addAdapter({{configuration::FilterDuplicates, true}, {configuration::UpcaseDataItemValue, true}}); @@ -1365,6 +1403,7 @@ TEST_F(AgentTest, UpcaseValues) } } +/// @test Tests whether conditions can be sequenced. TEST_F(AgentTest, ConditionSequence) { addAdapter({{configuration::FilterDuplicates, true}}); @@ -1544,6 +1583,7 @@ TEST_F(AgentTest, ConditionSequence) } } +/// @test Tests if data is still extracted when the last data item's value is empty. TEST_F(AgentTest, EmptyLastItemFromAdapter) { addAdapter({{configuration::FilterDuplicates, true}}); @@ -1605,6 +1645,7 @@ TEST_F(AgentTest, EmptyLastItemFromAdapter) } } +/// @test Tests if constant values are displayed in the agent. TEST_F(AgentTest, ConstantValue) { addAdapter(); @@ -1632,6 +1673,7 @@ TEST_F(AgentTest, ConstantValue) } } +/// @test Tests if data items are still recorded when preceded by bad data items. TEST_F(AgentTest, BadDataItem) { addAdapter(); @@ -1652,6 +1694,7 @@ TEST_F(AgentTest, BadDataItem) // --------------------- Adapter Commands ---------------------- +/// @test Tests if the adapter can recieve commands. TEST_F(AgentTest, AdapterCommands) { addAdapter(); @@ -1683,6 +1726,7 @@ TEST_F(AgentTest, AdapterCommands) } } +/// @test Tests commands to get device UUIDs. TEST_F(AgentTest, AdapterDeviceCommand) { m_agentTestHelper->createAgent("/samples/two_devices.xml"); @@ -1714,6 +1758,7 @@ TEST_F(AgentTest, AdapterDeviceCommand) ASSERT_EQ("another-uuid", string(*device1->getUuid())); } +/// @test Tests if the the adapter and MTConnect version can be set VIA command. TEST_F(AgentTest, adapter_command_should_set_adapter_and_mtconnect_versions) { m_agentTestHelper->createAgent("/samples/kinematics.xml", 8, 4, "1.7", 25); @@ -1764,6 +1809,7 @@ TEST_F(AgentTest, adapter_command_should_set_adapter_and_mtconnect_versions) } } +/// @test Tests whether the UUID can be changed VIA command. TEST_F(AgentTest, UUIDChange) { auto agent = m_agentTestHelper->getAgent(); @@ -1796,6 +1842,7 @@ TEST_F(AgentTest, UUIDChange) // ------------------------- Asset Tests --------------------------------- +/// @test Tests whether assets can be stored in the agent. TEST_F(AgentTest, AssetStorage) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 4, true); @@ -1831,6 +1878,7 @@ TEST_F(AgentTest, AssetStorage) } } +/// @test Tests whether assets can be stored in the agent buffer. TEST_F(AgentTest, AssetBuffer) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 4, true); @@ -2008,6 +2056,7 @@ TEST_F(AgentTest, AssetBuffer) } } +/// @test Tests whether the agent returns the correct error when an asset can not be found. TEST_F(AgentTest, AssetError) { { @@ -2018,6 +2067,7 @@ TEST_F(AgentTest, AssetError) } } +/// @test Tests the addition of new assets in the agent. TEST_F(AgentTest, AdapterAddAsset) { addAdapter(); @@ -2036,6 +2086,7 @@ TEST_F(AgentTest, AdapterAddAsset) } } +/// @test Tests the addition of multiline assets in the agent. TEST_F(AgentTest, MultiLineAsset) { addAdapter(); @@ -2074,6 +2125,7 @@ TEST_F(AgentTest, MultiLineAsset) } } +/// @test Tests whether bad assets get added to the agent. TEST_F(AgentTest, BadAsset) { addAdapter(); @@ -2086,6 +2138,7 @@ TEST_F(AgentTest, BadAsset) ASSERT_EQ((unsigned int)0, storage->getCount()); } +/// @test Tests the removal of assets from the agent. TEST_F(AgentTest, AssetRemoval) { string body = "TEST 1"; @@ -2180,6 +2233,7 @@ TEST_F(AgentTest, AssetRemoval) } } +/// @test Tests the removal of assets from the agent by the adapter. TEST_F(AgentTest, AssetRemovalByAdapter) { addAdapter(); @@ -2237,6 +2291,7 @@ TEST_F(AgentTest, AssetRemovalByAdapter) } } +/// @test Tests whether the agent reports the changing of assets. TEST_F(AgentTest, AssetAdditionOfAssetChanged12) { m_agentTestHelper->createAgent("/samples/min_config.xml", 8, 4, "1.2", 25); @@ -2249,6 +2304,7 @@ TEST_F(AgentTest, AssetAdditionOfAssetChanged12) } } +/// @test Tests whether the agent reports the removal of assets. TEST_F(AgentTest, AssetAdditionOfAssetRemoved13) { m_agentTestHelper->createAgent("/samples/min_config.xml", 8, 4, "1.3", 25); @@ -2261,6 +2317,7 @@ TEST_F(AgentTest, AssetAdditionOfAssetRemoved13) } } +/// @test Tests whether the agent reports the removal of assets. TEST_F(AgentTest, AssetAdditionOfAssetRemoved15) { m_agentTestHelper->createAgent("/samples/min_config.xml", 8, 4, "1.5", 25); @@ -2272,6 +2329,7 @@ TEST_F(AgentTest, AssetAdditionOfAssetRemoved15) } } +/// @test Tests if the agent prepends text to the assetIds. TEST_F(AgentTest, AssetPrependId) { addAdapter(); @@ -2291,6 +2349,7 @@ TEST_F(AgentTest, AssetPrependId) } } +/// @test Tests if the removal of assets triggers and assetChange. TEST_F(AgentTest, RemoveLastAssetChanged) { addAdapter(); @@ -2321,6 +2380,7 @@ TEST_F(AgentTest, RemoveLastAssetChanged) } } +/// @test Tests the removal of assets using the HTTP delete command. TEST_F(AgentTest, RemoveAssetUsingHttpDelete) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 4, true); @@ -2350,6 +2410,7 @@ TEST_F(AgentTest, RemoveAssetUsingHttpDelete) } } +/// @test Tests if the toggle to unavialable triggers an assetChange. TEST_F(AgentTest, AssetChangedWhenUnavailable) { addAdapter(); @@ -2361,6 +2422,7 @@ TEST_F(AgentTest, AssetChangedWhenUnavailable) } } +/// @test Tests the removal of all assets in the agent. TEST_F(AgentTest, RemoveAllAssets) { addAdapter(); @@ -2418,6 +2480,7 @@ TEST_F(AgentTest, RemoveAllAssets) } } +/// @test Tests asset probing. TEST_F(AgentTest, AssetProbe) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 4, true); @@ -2444,6 +2507,7 @@ TEST_F(AgentTest, AssetProbe) } } +/// @test Tests the the HTTP error responses to a PUT request to assets. TEST_F(AgentTest, ResponseToHTTPAssetPutErrors) { m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 4, true); @@ -2507,6 +2571,7 @@ TEST_F(AgentTest, ResponseToHTTPAssetPutErrors) } } +/// @test Tests the automatic update to the asset count data item. TEST_F(AgentTest, update_asset_count_data_item_v2_0) { m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 10, "2.0", 4, true); @@ -2584,6 +2649,7 @@ TEST_F(AgentTest, update_asset_count_data_item_v2_0) /// @name Streaming Tests /// Tests that validate HTTP long poll behavior of the agent + /// @test ensure an error is returned when the interval has an invalid value TEST_F(AgentTest, interval_should_be_a_valid_integer_value) { @@ -2624,6 +2690,7 @@ TEST_F(AgentTest, interval_should_be_a_valid_integer_value) } } + /// @test check streaming of data every 50ms TEST_F(AgentTest, should_stream_data_with_interval) { @@ -2684,6 +2751,7 @@ TEST_F(AgentTest, should_stream_data_with_interval) } } + /// @test Should stream data when observations arrive within the interval TEST_F(AgentTest, should_signal_observer_when_observations_arrive) { @@ -2718,6 +2786,7 @@ TEST_F(AgentTest, should_signal_observer_when_observations_arrive) } } + /// @test check request with from out of range TEST_F(AgentTest, should_fail_if_from_is_out_of_range) { @@ -2752,6 +2821,7 @@ TEST_F(AgentTest, should_fail_if_from_is_out_of_range) /// Tests that validate the HTTP PUT and POST behavior of the Agent when `AllowPuts` is /// enabled in the configuration file. + /// @test check if the agent allows making observations when put is allowed TEST_F(AgentTest, should_allow_making_observations_via_http_put) { @@ -2776,6 +2846,7 @@ TEST_F(AgentTest, should_allow_making_observations_via_http_put) } } + /// @test putting a condition requires the SHDR formatted data TEST_F(AgentTest, put_condition_should_parse_condition_data) { @@ -2800,6 +2871,7 @@ TEST_F(AgentTest, put_condition_should_parse_condition_data) } } +/// @test Tests if the 2.0 agent adds an asset_count data item. TEST_F(AgentTest, shound_add_asset_count_when_20) { m_agentTestHelper->createAgent("/samples/min_config.xml", 8, 4, "2.0", 25); @@ -2814,6 +2886,7 @@ TEST_F(AgentTest, shound_add_asset_count_when_20) } } +/// @test Tests if the asset count is returned in the header post in the 2.0 agent. TEST_F(AgentTest, asset_count_should_not_occur_in_header_post_20) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "2.0", 4, true); @@ -2840,6 +2913,7 @@ TEST_F(AgentTest, asset_count_should_not_occur_in_header_post_20) } } +/// @test Tests if the agent tracks asset types. TEST_F(AgentTest, asset_count_should_track_asset_additions_by_type) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "2.0", 4, true); @@ -2898,6 +2972,7 @@ TEST_F(AgentTest, asset_count_should_track_asset_additions_by_type) } } +/// @test Tests if the agent allows the addition of assets VIA HTTP POST. TEST_F(AgentTest, asset_should_also_work_using_post_with_assets) { auto agent = m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "2.0", 4, true); @@ -2916,6 +2991,7 @@ TEST_F(AgentTest, asset_should_also_work_using_post_with_assets) } } +/// @test Tests if pre_start hooks are called. TEST_F(AgentTest, pre_start_hook_should_be_called) { bool called = false; @@ -2932,6 +3008,7 @@ TEST_F(AgentTest, pre_start_hook_should_be_called) agent->stop(); } +/// @test Tests if pre_initialize hooks are called. TEST_F(AgentTest, pre_initialize_hooks_should_be_called) { bool called = false; @@ -2945,6 +3022,7 @@ TEST_F(AgentTest, pre_initialize_hooks_should_be_called) ASSERT_TRUE(called); } +/// @test Tests if post_initialize hooks are called. TEST_F(AgentTest, post_initialize_hooks_should_be_called) { bool called = false; @@ -2958,6 +3036,7 @@ TEST_F(AgentTest, post_initialize_hooks_should_be_called) ASSERT_TRUE(called); } +/// @test Tests if pre_stop hooks are called. TEST_F(AgentTest, pre_stop_hook_should_be_called) { static bool called = false; @@ -2975,6 +3054,7 @@ TEST_F(AgentTest, pre_stop_hook_should_be_called) ASSERT_TRUE(called); } +/// @test Tests if devices in the 2.2 agent have hashes. TEST_F(AgentTest, device_should_have_hash_for_2_2) { m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "2.2", 4, true); diff --git a/test_package/asset_buffer_test.cpp b/test_package/asset_buffer_test.cpp index 54d5c4076..ec7de0886 100644 --- a/test_package/asset_buffer_test.cpp +++ b/test_package/asset_buffer_test.cpp @@ -116,6 +116,7 @@ class AssetBufferTest : public testing::Test std::unique_ptr m_assetBuffer; }; +/// @test Tests if assets can be added to the asset buffer. TEST_F(AssetBufferTest, AddAsset) { ErrorList errors; @@ -128,6 +129,7 @@ TEST_F(AssetBufferTest, AddAsset) ASSERT_EQ(1, m_assetBuffer->getCountForDevice("D1")); } +/// @test Tests if assets can be updated in the asset buffer. TEST_F(AssetBufferTest, ReplaceAsset) { ErrorList errors; @@ -147,6 +149,7 @@ TEST_F(AssetBufferTest, ReplaceAsset) ASSERT_EQ(1, m_assetBuffer->getCountForDevice("D2")); } +/// @test Test if the agent handlke asset buffer overflows. TEST_F(AssetBufferTest, TestOverflow) { ErrorList errors; @@ -175,6 +178,7 @@ TEST_F(AssetBufferTest, TestOverflow) ASSERT_EQ(1, m_assetBuffer->getCountForDevice("D3")); } +/// @test Tests if the agent can remove assets. TEST_F(AssetBufferTest, RemovedAsset) { ErrorList errors; @@ -220,6 +224,7 @@ TEST_F(AssetBufferTest, RemovedAsset) ASSERT_EQ(1, m_assetBuffer->getCountForDevice("D3")); } +/// @test Tests if the asset counts are correct for types and devices. TEST_F(AssetBufferTest, verify_asset_counts_by_type) { m_assetBuffer = make_unique(12); @@ -248,6 +253,7 @@ TEST_F(AssetBufferTest, verify_asset_counts_by_type) ASSERT_EQ(5, counts3["Asset2"]); } +/// @test Tests if removing an asset correctly updates the asset counts. TEST_F(AssetBufferTest, verify_asset_counts_with_removal) { m_assetBuffer = make_unique(12); diff --git a/test_package/asset_hash_test.cpp b/test_package/asset_hash_test.cpp index 6d5529e48..8681eabca 100644 --- a/test_package/asset_hash_test.cpp +++ b/test_package/asset_hash_test.cpp @@ -69,6 +69,7 @@ class AssetHashTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +/// @test Tests if the assets are assigned hashes by the agent. TEST_F(AssetHashTest, should_assign_hash_when_receiving_asset) { addAdapter(); @@ -132,7 +133,8 @@ TEST_F(AssetHashTest, should_assign_hash_when_receiving_asset) ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:AssetChanged@hash", hash.c_str()); } } - + +/// @test Tests if the hash changes when the asset changes. TEST_F(AssetHashTest, hash_should_change_when_doc_changes) { addAdapter(); diff --git a/test_package/asset_test.cpp b/test_package/asset_test.cpp index 49e383f31..3a4671bbd 100644 --- a/test_package/asset_test.cpp +++ b/test_package/asset_test.cpp @@ -60,6 +60,7 @@ class AssetTest : public testing::Test std::unique_ptr m_writer; }; +/// @test Tests if assets can contain extended content. TEST_F(AssetTest, TestExtendedAsset) { auto doc = @@ -89,6 +90,7 @@ TEST_F(AssetTest, TestExtendedAsset) ASSERT_EQ(expected, m_writer->getContent()); } +/// @test Tests if the asset parses and loads when it has a missing asset Id. TEST_F(AssetTest, asset_should_parse_and_load_if_asset_id_is_missing_from_xml) { auto doc = R"DOC( diff --git a/test_package/change_observer_test.cpp b/test_package/change_observer_test.cpp index e3f90663a..41c76ec53 100644 --- a/test_package/change_observer_test.cpp +++ b/test_package/change_observer_test.cpp @@ -73,6 +73,7 @@ namespace mtconnect { std::optional m_guard; }; + /// @test Tests whether change observers can be added to signals. TEST_F(ChangeObserverTest, AddObserver) { mtconnect::ChangeObserver changeObserver(*m_strand); @@ -82,6 +83,7 @@ namespace mtconnect { ASSERT_TRUE(m_signaler->hasObserver(&changeObserver)); } + /// @test Tests whether the observer signals at the correct rate. TEST_F(ChangeObserverTest, SignalObserver) { mtconnect::ChangeObserver changeObserver(*m_strand); @@ -139,7 +141,8 @@ namespace mtconnect { ASSERT_FALSE(waitResult); ASSERT_FALSE(changeObserver.wasSignaled()); } - + + /// @test TEST_F(ChangeObserverTest, Cleanup) { mtconnect::ChangeObserver *changeObserver = nullptr; @@ -153,7 +156,8 @@ namespace mtconnect { ASSERT_FALSE(m_signaler->hasObserver(changeObserver)); } - + + /// @test Tests if the agent can handle sequences of changes. TEST_F(ChangeObserverTest, ChangeSequence) { mtconnect::ChangeObserver changeObserver(*m_strand); @@ -183,7 +187,8 @@ namespace mtconnect { ASSERT_EQ(uint64_t {100}, changeObserver.getSequence()); } - + + /// @test Tests if the agent can handle sequences of changes. TEST_F(ChangeObserverTest, ChangeSequence2) { using namespace std::chrono_literals; @@ -292,7 +297,8 @@ namespace mtconnect { DevicePtr m_device; ComponentPtr m_comp; }; - + + /// @test Tests if the async observer calls the handler. TEST_F(AsyncObserverTest, async_observer_should_call_handler) { FilterSet filter {"a", "b"}; @@ -325,7 +331,8 @@ namespace mtconnect { waitFor([&called]() { return called; }); ASSERT_TRUE(called); } - + + /// @test Tests if the async observer calls the handler immediately if not at the end of the buffer. TEST_F(AsyncObserverTest, if_not_at_end_should_call_immediately) { FilterSet filter {"a", "b"}; @@ -367,7 +374,8 @@ namespace mtconnect { waitFor([&called]() { return called; }); ASSERT_TRUE(called); } - + + /// @test Tests if the observations are processed in small batches. TEST_F(AsyncObserverTest, process_observations_in_small_chunks) { FilterSet filter {"a", "b"}; @@ -430,7 +438,8 @@ namespace mtconnect { ASSERT_EQ(5, observer->getSequence()); ASSERT_FALSE(observer->isEndOfBuffer()); } - + + /// @test Tests if the handler is called on the heartbeat event. TEST_F(AsyncObserverTest, should_call_handler_with_heartbeat) { FilterSet filter {"a", "b"}; @@ -465,7 +474,8 @@ namespace mtconnect { ASSERT_EQ(4, observer->getSequence()); ASSERT_TRUE(observer->isEndOfBuffer()); } - + + /// @test Tests if the async observer stops when it isn't running. TEST_F(AsyncObserverTest, should_stop_if_not_running) { FilterSet filter {"a", "b"}; diff --git a/test_package/checkpoint_test.cpp b/test_package/checkpoint_test.cpp index 5af6a77b2..7809e619f 100644 --- a/test_package/checkpoint_test.cpp +++ b/test_package/checkpoint_test.cpp @@ -84,6 +84,7 @@ class CheckpointTest : public testing::Test DevicePtr m_device; }; +/// @test Tests the creation of observations. TEST_F(CheckpointTest, AddObservations) { entity::ErrorList errors; @@ -151,6 +152,7 @@ TEST_F(CheckpointTest, AddObservations) EXPECT_EQ(1, p5.use_count()); } +/// @test Tests copying of observations. TEST_F(CheckpointTest, Copy) { entity::ErrorList errors; @@ -184,6 +186,7 @@ TEST_F(CheckpointTest, Copy) ASSERT_EQ(2, p2.use_count()); } +/// @test Tests the retreival of observations. TEST_F(CheckpointTest, GetObservations) { entity::ErrorList errors; @@ -241,6 +244,7 @@ TEST_F(CheckpointTest, GetObservations) ASSERT_EQ(2, list2.size()); } +/// @test Tests the filtering of copied observations. TEST_F(CheckpointTest, Filter) { entity::ErrorList errors; @@ -294,6 +298,7 @@ TEST_F(CheckpointTest, Filter) d1.reset(); } +/// @test Tests the copying of observations TEST_F(CheckpointTest, CopyAndFilter) { entity::ErrorList errors; @@ -364,6 +369,7 @@ TEST_F(CheckpointTest, CopyAndFilter) ASSERT_EQ(3, list.size()); } +/// @test Tests the chaining of condition observations. TEST_F(CheckpointTest, ConditionChaining) { entity::ErrorList errors; @@ -487,6 +493,7 @@ TEST_F(CheckpointTest, ConditionChaining) ASSERT_EQ(1, (int)list.size()); } +/// @test Tests if filtering alters the condition observation's value. TEST_F(CheckpointTest, LastConditionNormal) { entity::ErrorList errors; @@ -523,6 +530,7 @@ TEST_F(CheckpointTest, LastConditionNormal) ASSERT_EQ(string(""), p3->getCode()); } +/// @test Tests if observations without dataitems are skipped. TEST_F(CheckpointTest, orphaned_observations_should_be_skipped) { entity::ErrorList errors; diff --git a/test_package/circular_buffer_test.cpp b/test_package/circular_buffer_test.cpp index ca19a6ea2..a663ad3bb 100644 --- a/test_package/circular_buffer_test.cpp +++ b/test_package/circular_buffer_test.cpp @@ -133,6 +133,7 @@ class CircularBufferTest : public testing::Test ComponentPtr m_comp2; }; +/// @test Tests add and get observations. TEST_F(CircularBufferTest, should_add_observations_and_get_list) { addSomeObservations(); @@ -151,6 +152,7 @@ TEST_F(CircularBufferTest, should_add_observations_and_get_list) ASSERT_TRUE(eob); } +/// @test Tests add and get observations when retrieving a limited amount of observations. TEST_F(CircularBufferTest, should_add_observations_and_get_limited) { addSomeObservations(); @@ -169,6 +171,7 @@ TEST_F(CircularBufferTest, should_add_observations_and_get_limited) ASSERT_FALSE(eob); } +/// @test Tests add and get observations when observations are orphaned. TEST_F(CircularBufferTest, should_skip_orphaned_observations) { addSomeObservations(); diff --git a/test_package/component_parameters_test.cpp b/test_package/component_parameters_test.cpp index 5b5c52949..930c50ff5 100644 --- a/test_package/component_parameters_test.cpp +++ b/test_package/component_parameters_test.cpp @@ -66,6 +66,7 @@ class ComponentParametersTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +/// @test Tests the parsing of simple parameters sets for components. TEST_F(ComponentParametersTest, should_parse_simple_parameter_set) { const auto doc = @@ -144,6 +145,7 @@ TEST_F(ComponentParametersTest, should_parse_simple_parameter_set) ASSERT_NE(hash1, entity->hash()); } +/// @test Tests the parsing of two parameters sets for components. TEST_F(ComponentParametersTest, should_parse_two_parameter_sets) { const auto doc = diff --git a/test_package/component_test.cpp b/test_package/component_test.cpp index 53c8c583c..9b70dfb58 100644 --- a/test_package/component_test.cpp +++ b/test_package/component_test.cpp @@ -67,6 +67,7 @@ class ComponentTest : public testing::Test ComponentPtr m_compB; }; +/// @test Tests getters for components. TEST_F(ComponentTest, Getters) { ASSERT_EQ((string) "Axes", string(m_compA->getName())); @@ -82,7 +83,9 @@ TEST_F(ComponentTest, Getters) ASSERT_FALSE(m_compB->hasProperty("nativeName")); } + // Workning our way through +/// @test Tests component attributes. TEST_F(ComponentTest, Description) { map attributes; @@ -111,6 +114,7 @@ TEST_F(ComponentTest, Description) ASSERT_FALSE(d2->hasValue()); } +/// @test tests component relationships. TEST_F(ComponentTest, Relationships) { // Test get/set parents @@ -142,6 +146,7 @@ TEST_F(ComponentTest, Relationships) ASSERT_EQ(2, m_compA.use_count()); } +/// @test Tests component data items. TEST_F(ComponentTest, DataItems) { ASSERT_FALSE(m_compA->getDataItems()); @@ -165,7 +170,9 @@ TEST_F(ComponentTest, DataItems) } // Not relevant right now. Tested as references in other places + #if 0 +/// @test Tests component references. TEST_F(ComponentTest, References) { diff --git a/test_package/composition_test.cpp b/test_package/composition_test.cpp index b9e75879b..055778dcd 100644 --- a/test_package/composition_test.cpp +++ b/test_package/composition_test.cpp @@ -65,6 +65,7 @@ class CompositionTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +/// @test Tests the parsing of device-component relationships. TEST_F(CompositionTest, ParseDeviceAndComponentRelationships) { using namespace mtconnect::entity; @@ -114,6 +115,7 @@ TEST_F(CompositionTest, ParseDeviceAndComponentRelationships) #define CONFIGURATION_PATH COMPOSITION_PATH "/m:Configuration" #define SPECIFICATIONS_PATH CONFIGURATION_PATH "/m:Specifications" +/// @test Tests if XML is printed correctly. TEST_F(CompositionTest, XmlPrinting) { { @@ -135,6 +137,7 @@ TEST_F(CompositionTest, XmlPrinting) } } +/// @test Tests if JSON is printed correctly. TEST_F(CompositionTest, JsonPrinting) { { @@ -160,6 +163,7 @@ TEST_F(CompositionTest, JsonPrinting) } } +/// @test Tests if compositions create their own topics. TEST_F(CompositionTest, should_create_topic) { using namespace mtconnect::entity; diff --git a/test_package/config_parser_test.cpp b/test_package/config_parser_test.cpp index 2bc8f9872..a67f8a881 100644 --- a/test_package/config_parser_test.cpp +++ b/test_package/config_parser_test.cpp @@ -32,6 +32,7 @@ int main(int argc, char *argv[]) return RUN_ALL_TESTS(); } +/// @test Tests if simple properties can be parsed. TEST(ConfigParserTest, parse_simple_properties) { string cfg = R"DOC( @@ -45,6 +46,7 @@ mellon = water ASSERT_EQ("water", tree.get("mellon")); } +/// @test Test the parsing of configuration nested properties. TEST(ConfigParserTest, parse_with_subtree) { string cfg = R"DOC( @@ -65,6 +67,7 @@ animals { ASSERT_EQ("bench", animals->second.get("cows")); } +/// @test Tests error raising when an invalid configuration is input. TEST(ConfigParserTest, skip_comments_starting_with_hash) { string cfg = R"DOC( @@ -87,6 +90,7 @@ animals { ASSERT_EQ("bench", animals->second.get("cows")); } +/// @test Tests error raising when an invalid configuration is input. TEST(ConfigParserTest, invalid_config) { string cfg = R"DOC( @@ -97,6 +101,7 @@ a = b ASSERT_THROW(Parser::parse(cfg), ParseError); } +/// @test Tests error raising when an invalid configuration is input (no closing curly brace). TEST(ConfigParserTest, no_closing_curly) { string cfg = R"DOC( @@ -107,6 +112,7 @@ a { dog=cat ASSERT_THROW(Parser::parse(cfg), ParseError); } +/// @test Tests error raising when an invalid configuration is input (missing value). TEST(ConfigParserTest, missing_value) { string cfg = R"DOC( @@ -117,6 +123,7 @@ cow = bull ASSERT_THROW(Parser::parse(cfg), ParseError); } +/// @test Tests configuration parsing when the last value ends with a curly brace. TEST(ConfigParserTest, last_property_ending_with_curly) { string cfg = R"DOC( @@ -137,6 +144,7 @@ animals { ASSERT_EQ("bench", animals->second.get("cows")); } +/// @test Tests configuration parsing it consists of a single line block. TEST(ConfigParserTest, single_line_block) { string cfg = "parents { mother = father }"; diff --git a/test_package/config_test.cpp b/test_package/config_test.cpp index 542763b05..e03cfd373 100644 --- a/test_package/config_test.cpp +++ b/test_package/config_test.cpp @@ -123,6 +123,7 @@ namespace { std::filesystem::path m_cwd; }; + /// @test Tests the loading of a blank configuration. TEST_F(ConfigTest, BlankConfig) { m_config->loadConfig(""); @@ -133,6 +134,7 @@ namespace { ASSERT_EQ("1.1", *agent->getSchemaVersion()); } + /// @test Tests loading of a configuration specifying buffer size. TEST_F(ConfigTest, BufferSize) { m_config->loadConfig("BufferSize = 4\n"); @@ -144,6 +146,7 @@ namespace { ASSERT_EQ(16U, circ.getBufferSize()); } + /// @test Tests loading of a configuration specifying a device. TEST_F(ConfigTest, Device) { string str("Devices = " TEST_RESOURCE_DIR "/samples/test_config.xml\n"); @@ -166,6 +169,7 @@ namespace { ASSERT_TRUE(device->preserveUuid()); } + /// @test Tests loading of a configuration specifying an adapter TEST_F(ConfigTest, Adapter) { using namespace std::chrono_literals; @@ -200,6 +204,7 @@ namespace { // ASSERT_TRUE(device->m_preserveUuid); } + /// @test Tests the perserveUUID configuration parameter. TEST_F(ConfigTest, DefaultPreserveUUID) { string str("Devices = " TEST_RESOURCE_DIR @@ -214,6 +219,7 @@ namespace { ASSERT_TRUE(device->preserveUuid()); } + /// @test Tests the override of perserveUUID by the last specified value. TEST_F(ConfigTest, DefaultPreserveOverride) { string str("Devices = " TEST_RESOURCE_DIR @@ -231,6 +237,7 @@ namespace { ASSERT_FALSE(device->preserveUuid()); } + /// @test Tests the allowPut configuration parameter. TEST_F(ConfigTest, DisablePut) { string str("Devices = " TEST_RESOURCE_DIR @@ -247,6 +254,7 @@ namespace { ASSERT_TRUE(rest->getServer()->arePutsAllowed()); } + /// @test Tests the allowPut configuration parameter with a specific host. TEST_F(ConfigTest, LimitPut) { string str("Devices = " TEST_RESOURCE_DIR @@ -265,6 +273,7 @@ namespace { ASSERT_TRUE(rest->getServer()->allowPutFrom(std::string("127.0.0.1"))); } + /// @test Tests the allowPut configuration parameter with specific hosts. TEST_F(ConfigTest, LimitPutFromHosts) { string str("Devices = " TEST_RESOURCE_DIR @@ -284,6 +293,7 @@ namespace { ASSERT_TRUE(rest->getServer()->allowPutFrom(std::string("192.168.0.1"))); } + /// @test Tests the addition of namespaces using the configuration file. TEST_F(ConfigTest, Namespaces) { string streams( @@ -356,6 +366,7 @@ namespace { ASSERT_EQ(std::string("urn:example.com:ExampleErrors:1.2"), path); } + /// @test Tests the legacyTimeout parameter in the configuration file. TEST_F(ConfigTest, LegacyTimeout) { using namespace std::chrono_literals; @@ -372,6 +383,7 @@ namespace { ASSERT_EQ(2000s, adapter->getLegacyTimeout()); } + /// @test Tests the IgnoreTimestamps parameter in the configuration file. TEST_F(ConfigTest, IgnoreTimestamps) { string str("Devices = " TEST_RESOURCE_DIR @@ -386,6 +398,7 @@ namespace { ASSERT_TRUE(IsOptionSet(adapter->getOptions(), configuration::IgnoreTimestamps)); } + /// @test Tests the override of IgnoreTimestamps by the last specified value. TEST_F(ConfigTest, IgnoreTimestampsOverride) { string str("Devices = " TEST_RESOURCE_DIR @@ -404,6 +417,7 @@ namespace { ASSERT_FALSE(IsOptionSet(adapter->getOptions(), configuration::IgnoreTimestamps)); } + /// @test Tests the addition of MTConnect namespaces using the configuration file. TEST_F(ConfigTest, SpecifyMTCNamespace) { string streams( @@ -428,6 +442,7 @@ namespace { printer->clearStreamsNamespaces(); } + /// @test Tests the SchemaVersion parameter in the configuration file. TEST_F(ConfigTest, SetSchemaVersion) { string streams("SchemaVersion = 1.4\n"); @@ -444,6 +459,7 @@ namespace { printer->setSchemaVersion("1.3"); } + /// @test Tests the schema.path parameter in the configuration file. TEST_F(ConfigTest, SchemaDirectory) { string schemas( @@ -487,6 +503,7 @@ namespace { ASSERT_EQ(std::string("/schemas/MTConnectError_1.3.xsd"), location); } + /// @test Tests the access control limitation in the configuration file. TEST_F(ConfigTest, check_http_headers) { string str( @@ -513,6 +530,7 @@ namespace { ASSERT_EQ(" *", first.second); } + /// @test Tests dynamic loading of sinks. TEST_F(ConfigTest, dynamic_load_sinks_bad) { string str(R"( @@ -534,6 +552,7 @@ Sinks { ASSERT_TRUE(sink == nullptr); } + /// @test Tests dynamic loading of sinks. TEST_F(ConfigTest, dynamic_load_sinks_simple) { string str(R"( @@ -552,6 +571,7 @@ Sinks { ASSERT_TRUE(sink != nullptr); } + /// @test Tests dynamic loading of sinks with plugin block. TEST_F(ConfigTest, dynamic_load_sinks_with_plugin_block) { string str(R"( @@ -574,6 +594,7 @@ Sinks { ASSERT_TRUE(sink != nullptr); } + /// @test Tests dynamic loading of sinks with an assigned name. TEST_F(ConfigTest, dynamic_load_sinks_assigned_name) { string str(R"( @@ -594,6 +615,7 @@ Sinks { ASSERT_TRUE(sink2 != nullptr); } + /// @test Tests dynamic loading of sinks with an assigned nametag. TEST_F(ConfigTest, dynamic_load_sinks_assigned_name_tag) { string str(R"( @@ -616,6 +638,7 @@ Sinks { } // + /// @test Tests dynamic loading of adapters. TEST_F(ConfigTest, dynamic_load_adapter_bad) { string str(R"( @@ -635,6 +658,7 @@ Adapters { ASSERT_TRUE(adapter == nullptr); } + /// @test Tests dynamic loading of adapters. TEST_F(ConfigTest, dynamic_load_adapter_simple) { string str(R"( @@ -654,6 +678,7 @@ Adapters { ASSERT_TRUE(adapter != nullptr); } + /// @test Tests dynamic loading of adapters with plugin block. TEST_F(ConfigTest, dynamic_load_adapter_with_plugin_block) { string str(R"( @@ -678,6 +703,7 @@ Adapters { ASSERT_TRUE(adapter != nullptr); } + /// @test Tests the specifying of maximum cache size when units are omitted. TEST_F(ConfigTest, max_cache_size_in_no_units) { string str(R"( @@ -696,6 +722,7 @@ MaxCachedFileSize = 2000 ASSERT_EQ(2000, cache->getMaxCachedFileSize()); } + /// @test Tests the specifying of maximum cache size when units are kilobytes. TEST_F(ConfigTest, max_cache_size_in_kb) { string str(R"( @@ -714,6 +741,7 @@ MaxCachedFileSize = 2k ASSERT_EQ(2048, cache->getMaxCachedFileSize()); } + /// @test Tests the specifying of maximum cache size when units are kilobytes uppercase. TEST_F(ConfigTest, max_cache_size_in_Kb_in_uppercase) { string str(R"( @@ -732,6 +760,7 @@ MaxCachedFileSize = 2K ASSERT_EQ(2048, cache->getMaxCachedFileSize()); } + /// @test Tests the specifying of maximum cache size when units are megabytes. TEST_F(ConfigTest, max_cache_size_in_mb) { string str(R"( @@ -750,6 +779,7 @@ MaxCachedFileSize = 2m ASSERT_EQ(2 * 1024 * 1024, cache->getMaxCachedFileSize()); } + /// @test Tests the specifying of maximum cache size when units are gigabytes. TEST_F(ConfigTest, max_cache_size_in_gb) { string str(R"( @@ -771,6 +801,7 @@ MaxCachedFileSize = 2g #define EXPECT_PATH_EQ(p1, p2) \ EXPECT_EQ(std::filesystem::weakly_canonical(p1), std::filesystem::weakly_canonical(p2)) + /// @test Tests the updating ot he log file archive file name based on logger_config.output in the configuration file. TEST_F(ConfigTest, log_output_should_set_archive_file_pattern) { m_config->setDebug(false); @@ -791,6 +822,7 @@ logger_config { EXPECT_PATH_EQ(TEST_BIN_ROOT_DIR, m_config->getLogDirectory()); } + /// @test Tests modification of the log file name based on logger_config.output in the configuration file. TEST_F(ConfigTest, log_output_should_configure_file_name) { m_config->setDebug(false); @@ -811,6 +843,7 @@ logger_config { EXPECT_PATH_EQ(TEST_BIN_ROOT_DIR, m_config->getLogDirectory()); } + /// @test Tests modification of the log file name based on logger_config.file_name and logger_config.archive_pattern in the configuration file. TEST_F(ConfigTest, log_should_configure_file_name) { m_config->setDebug(false); @@ -832,6 +865,7 @@ logger_config { EXPECT_PATH_EQ(TEST_BIN_ROOT_DIR, m_config->getLogDirectory()); } + /// @test Tests if logger_config.file_name and logger_config.archive_pattern use relative file paths. TEST_F(ConfigTest, log_should_specify_relative_directory) { m_config->setDebug(false); @@ -855,6 +889,7 @@ logger_config { EXPECT_PATH_EQ(path, m_config->getLogDirectory()); } + /// @test Tests if logger_config.file_name and logger_config.archive_pattern use relative file paths using the parent. TEST_F(ConfigTest, log_should_specify_relative_directory_with_active_in_parent) { m_config->setDebug(false); @@ -878,6 +913,7 @@ logger_config { EXPECT_PATH_EQ(path / "logs", m_config->getLogDirectory()); } + /// @test Tests the logger_config.max_size and logger_config.rotation_size parameters in the configuration file. TEST_F(ConfigTest, log_should_specify_max_file_and_rotation_size) { m_config->setDebug(false); @@ -900,6 +936,7 @@ logger_config { EXPECT_EQ(20ll * 1024 * 1024 * 1024, m_config->getLogRotationSize()); } + /// @test Tests the logger_config.level parameter in the configuration file. TEST_F(ConfigTest, log_should_configure_logging_level) { m_config->setDebug(false); @@ -962,6 +999,7 @@ logger_config { EXPECT_EQ(severity_level::fatal, m_config->getLogLevel()); } + /// @test Tests the reloading of device XML files using the MonitorConfigFiles, MonitorInterval, and MinimumConfigReloadAge parameters. TEST_F(ConfigTest, should_reload_device_xml_file) { auto root {createTempDirectory("1")}; @@ -1041,6 +1079,7 @@ Port = 0 m_config->start(); } + /// @test Tests if reloading the device XML files using the MonitorConfigFiles, MonitorInterval, and MinimumConfigReloadAge parameters skips unchanged devices. TEST_F(ConfigTest, should_reload_device_xml_and_skip_unchanged_devices) { fs::path root {createTempDirectory("2")}; @@ -1107,6 +1146,7 @@ Port = 0 m_config->start(); } + /// @test Tests the reloading of the config file using the MonitorConfigFiles, MonitorInterval, and MinimumConfigReloadAge parameters. TEST_F(ConfigTest, should_restart_agent_when_config_file_changes) { fs::path root {createTempDirectory("3")}; @@ -1182,6 +1222,7 @@ Port = 0 th.join(); } + /// @test Tests reloading the device XML files using the MonitorConfigFiles, MonitorInterval, and MinimumConfigReloadAge parameters adds new devices. TEST_F(ConfigTest, should_reload_device_xml_and_add_new_devices) { fs::path root {createTempDirectory("4")}; @@ -1269,6 +1310,7 @@ Port = 0 m_config->start(); } + /// @test Tests the DisableAgentDevice configuration parameter in the 2.0 agent. TEST_F(ConfigTest, should_disable_agent_device) { string streams("SchemaVersion = 2.0\nDisableAgentDevice = true\n"); @@ -1284,6 +1326,7 @@ Port = 0 ASSERT_EQ("Device", device->getName()); } + /// @test Tests if the default option for DisableAgentDevice is to enable the agent device. TEST_F(ConfigTest, should_default_not_disable_agent_device) { string streams("SchemaVersion = 2.0\n"); @@ -1299,6 +1342,7 @@ Port = 0 ASSERT_EQ("Agent", device->getName()); } + /// @test Tests if the schema version updates when the device file updates. TEST_F(ConfigTest, should_update_schema_version_when_device_file_updates) { auto root {createTempDirectory("5")}; @@ -1392,6 +1436,7 @@ Port = 0 th.join(); } + /// @test Tests if device models can be recieved from adapters when EnableSourceDeviceModels is set to true. TEST_F(ConfigTest, should_add_a_new_device_when_deviceModel_received_from_adapter) { using namespace mtconnect::source::adapter; @@ -1507,6 +1552,7 @@ Adapters { m_config->start(); } + /// @test Tests the updating of the devices.xml file when a device is recieved from an adapter. TEST_F(ConfigTest, should_update_a_device_when_received_from_adapter) { using namespace mtconnect::source::adapter; @@ -1640,6 +1686,7 @@ Port = 0 m_config->start(); } + /// @test Tests the updating of entity Ids using the CreateUniqueIds configuration parameter.. TEST_F(ConfigTest, should_update_the_ids_of_all_entities) { fs::path root {createTempDirectory("8")}; @@ -1698,6 +1745,7 @@ Port = 0 ASSERT_EQ("exec", *exec2->getOriginalId()); } + /// @test Tests the dyanmic addition of new devices with duplicate Ids. TEST_F(ConfigTest, should_add_a_new_device_with_duplicate_ids) { using namespace mtconnect::source::adapter; @@ -1813,6 +1861,7 @@ Port = 0 m_config->start(); } + /// @test Tests if xmlns are ignored when parsing the device xml. TEST_F(ConfigTest, should_ignore_xmlns_when_parsing_device_xml) { using namespace mtconnect::source::adapter; @@ -1919,6 +1968,7 @@ Adapters { m_config->start(); } + /// @test Tests the reloading when MonitorConfigFiles is set for true. TEST_F(ConfigTest, should_not_reload_when_monitor_files_is_on) { using namespace mtconnect::source::adapter; @@ -2045,6 +2095,7 @@ Port = 0 m_config->start(); } + /// @test Tests if the agent crashes when the agent recieves data when no devices are registered. TEST_F(ConfigTest, should_not_crash_when_there_are_no_devices_and_receives_data) { using namespace mtconnect::source::adapter; @@ -2123,6 +2174,7 @@ Adapters { } // Environment variable tests + /// @test Tests if the environemnt variables are expanded in the confiuration file. TEST_F(ConfigTest, should_expand_environment_variables) { putenv(strdup("CONFIG_TEST=TestValue")); @@ -2138,6 +2190,7 @@ ServiceName=$CONFIG_TEST ASSERT_EQ("TestValue", *GetOption(options, configuration::ServiceName)); } + /// @test Tests if options are expanded in the confiuration file. TEST_F(ConfigTest, should_expand_options) { putenv(strdup("CONFIG_TEST=ShouldNotMatch")); @@ -2155,6 +2208,7 @@ ServiceName=$TestVariable } // Environment variable tests + /// @test Tests if the prefixes and suffixes are expanded in the confiuration file. TEST_F(ConfigTest, should_expand_with_prefix_and_suffix) { putenv(strdup("CONFIG_TEST=TestValue")); @@ -2171,6 +2225,7 @@ ServiceName=/some/prefix/$CONFIG_TEST:suffix *GetOption(options, configuration::ServiceName)); } + /// @test Tests if the prefixes and suffixes are expanded in the confiuration file when curly braces are used. TEST_F(ConfigTest, should_expand_with_prefix_and_suffix_with_curly) { putenv(strdup("CONFIG_TEST=TestValue")); @@ -2187,6 +2242,7 @@ ServiceName="some_prefix_${CONFIG_TEST}_suffix" *GetOption(options, configuration::ServiceName)); } + /// @test Tests if the devices file can be found in the ConfigPath confiuration parameter. TEST_F(ConfigTest, should_find_device_file_in_config_path) { fs::path root {createTempDirectory("13")}; @@ -2204,6 +2260,7 @@ ServiceName="some_prefix_${CONFIG_TEST}_suffix" ASSERT_TRUE(m_config->getAgent()); } + /// @test Tests if the configuration file supports JSON formatting. TEST_F(ConfigTest, should_support_json_format) { using namespace std::chrono_literals; @@ -2244,6 +2301,7 @@ ServiceName="some_prefix_${CONFIG_TEST}_suffix" // ASSERT_TRUE(device->m_preserveUuid); } + /// @test Tests if the agent UUID can be set in the confiuration file with the AgentDeviceUUID parameter. TEST_F(ConfigTest, should_set_agent_device_uuid) { string config(R"DOC( diff --git a/test_package/connector_test.cpp b/test_package/connector_test.cpp index 480179032..0de3087b9 100644 --- a/test_package/connector_test.cpp +++ b/test_package/connector_test.cpp @@ -281,6 +281,8 @@ TEST_F(ConnectorTest, should_process_a_protocol_command) ASSERT_EQ("* Hello Connector", m_connector->m_command); } + +/// @test Tests the cconnector's heartbeat. TEST_F(ConnectorTest, Heartbeat) { // Start the accept thread @@ -301,6 +303,7 @@ TEST_F(ConnectorTest, Heartbeat) ASSERT_EQ(std::chrono::milliseconds {1000}, m_connector->heartbeatFrequency()); } +/// @test Tests the heartbeat's pong. TEST_F(ConnectorTest, HeartbeatPong) { // TODO Copy&Paste from Heartbeat @@ -337,6 +340,7 @@ TEST_F(ConnectorTest, HeartbeatPong) } } +/// @test Tests the heartbeat's keep alive. TEST_F(ConnectorTest, HeartbeatDataKeepAlive) { startServer(); @@ -371,6 +375,7 @@ TEST_F(ConnectorTest, HeartbeatDataKeepAlive) } } +/// @test Tests the heartbeat's timeout. TEST_F(ConnectorTest, HeartbeatTimeout) { startServer(); @@ -394,6 +399,7 @@ TEST_F(ConnectorTest, HeartbeatTimeout) ASSERT_TRUE(m_connector->m_disconnected); } +/// @test Test the legacy heartbeat's timeout. TEST_F(ConnectorTest, LegacyTimeout) { startServer(); @@ -414,6 +420,7 @@ TEST_F(ConnectorTest, LegacyTimeout) ASSERT_TRUE(m_connector->m_disconnected); } +/// @test Tests the connector's ability to parse the buffer. TEST_F(ConnectorTest, ParseBuffer) { startServer(); @@ -445,6 +452,7 @@ TEST_F(ConnectorTest, ParseBuffer) ASSERT_EQ((string) "And Again", m_connector->m_data); } +/// @test Tests the connector's ability to parse buffer frames. TEST_F(ConnectorTest, ParseBufferFraming) { startServer(); @@ -464,6 +472,7 @@ TEST_F(ConnectorTest, ParseBufferFraming) ASSERT_EQ((string) "fourth", m_connector->m_list[3]); } +/// @test Tests sending commands through the connector. TEST_F(ConnectorTest, SendCommand) { startServer(); @@ -481,6 +490,7 @@ TEST_F(ConnectorTest, SendCommand) ASSERT_EQ("* Hello There;", line); } +/// @test Tests IPV6 connections through the connector. TEST_F(ConnectorTest, IPV6Connection) { // TODO: Need to port to Windows > VISTA @@ -498,6 +508,7 @@ TEST_F(ConnectorTest, IPV6Connection) #endif } +/// @test Tests if the heartbeats begin when a valid pong is recieved. TEST_F(ConnectorTest, should_start_heartbeats_when_a_valid_pong_is_received) { ASSERT_TRUE(!m_connector->heartbeats()); @@ -543,6 +554,7 @@ TEST_F(ConnectorTest, should_start_heartbeats_when_a_valid_pong_is_received) ASSERT_EQ(std::chrono::milliseconds {323}, m_connector->heartbeatFrequency()); } +/// @test Tests filtering of trailing and leading white space in connector messages. TEST_F(ConnectorTest, test_trimming_trailing_white_space) { startServer(); diff --git a/test_package/coordinate_system_test.cpp b/test_package/coordinate_system_test.cpp index 3b9c380a0..c5a4de60b 100644 --- a/test_package/coordinate_system_test.cpp +++ b/test_package/coordinate_system_test.cpp @@ -63,6 +63,8 @@ class CoordinateSystemTest : public testing::Test std::unique_ptr m_agentTestHelper; }; + +/// @test Test device and component relationship parsing. TEST_F(CoordinateSystemTest, ParseDeviceAndComponentRelationships) { ASSERT_NE(nullptr, m_device); @@ -111,6 +113,7 @@ TEST_F(CoordinateSystemTest, ParseDeviceAndComponentRelationships) #define CONFIGURATION_PATH "//m:Device/m:Configuration" #define COORDINATE_SYSTEMS_PATH CONFIGURATION_PATH "/m:CoordinateSystems" +/// @test Test XML printing of coordinate systems. TEST_F(CoordinateSystemTest, XmlPrinting) { { @@ -149,6 +152,7 @@ TEST_F(CoordinateSystemTest, XmlPrinting) } } +/// @test Test JSON printing of coordinate systems. TEST_F(CoordinateSystemTest, JsonPrinting) { { diff --git a/test_package/cutting_tool_test.cpp b/test_package/cutting_tool_test.cpp index 85e7afe14..5485ea4e8 100644 --- a/test_package/cutting_tool_test.cpp +++ b/test_package/cutting_tool_test.cpp @@ -85,6 +85,7 @@ class CuttingToolTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +/// @test Tests minimal cutting tool archetype. TEST_F(CuttingToolTest, TestMinmalArchetype) { const auto doc = @@ -144,6 +145,7 @@ TEST_F(CuttingToolTest, TestMinmalArchetype) ASSERT_EQ(content, doc); } +/// @test Tests measurements for cutting tools. TEST_F(CuttingToolTest, TestMeasurements) { const auto doc = @@ -203,6 +205,7 @@ TEST_F(CuttingToolTest, TestMeasurements) ASSERT_EQ(content, doc); } +/// @test Tests cutting items. TEST_F(CuttingToolTest, TestItems) { const auto doc = @@ -336,6 +339,7 @@ TEST_F(CuttingToolTest, TestItems) ASSERT_EQ(content, doc); } +/// @test Tests minimal implementation of a cutting tool. TEST_F(CuttingToolTest, TestMinmalTool) { const auto doc = @@ -395,6 +399,7 @@ TEST_F(CuttingToolTest, TestMinmalTool) ASSERT_EQ(content, doc); } +/// @test Tests that an error when cutterStatus is not implemented. TEST_F(CuttingToolTest, TestMinmalToolError) { const auto doc = @@ -418,6 +423,7 @@ TEST_F(CuttingToolTest, TestMinmalToolError) ASSERT_EQ("CuttingTool: Invalid element 'CuttingToolLifeCycle'", string(errors.back()->what())); } +/// @test Tests that an error occurs when measurements are not properly implemented. TEST_F(CuttingToolTest, TestMeasurementsError) { const auto doc = @@ -458,6 +464,7 @@ TEST_F(CuttingToolTest, TestMeasurementsError) EXPECT_EQ("CuttingToolLifeCycle: Invalid element 'Measurements'", string((*it)->what())); } +/// @test Tests the implementation of an asset with multiple simple cutting items. TEST_F(CuttingToolTest, AssetWithSimpleCuttingItems) { auto printer = dynamic_cast(m_agentTestHelper->m_agent->getPrinter("xml")); @@ -494,6 +501,7 @@ TEST_F(CuttingToolTest, AssetWithSimpleCuttingItems) } } +/// @test Tests the extension of a cutting item with additional descriptive data items. TEST_F(CuttingToolTest, test_extended_cutting_item) { const auto doc = @@ -635,6 +643,7 @@ TEST_F(CuttingToolTest, test_extended_cutting_item) sdoc); } +/// @test Tests XML name space with a top element alias. TEST_F(CuttingToolTest, test_xmlns_with_top_element_alias) { const auto doc = @@ -694,6 +703,7 @@ TEST_F(CuttingToolTest, test_xmlns_with_top_element_alias) )DOC"); } +/// @test Tests if the cutter status data component is positioned before locus. TEST_F(CuttingToolTest, element_order_should_place_cutter_status_before_locus) { const auto doc = diff --git a/test_package/data_item_mapping_test.cpp b/test_package/data_item_mapping_test.cpp index edab04946..aa5206566 100644 --- a/test_package/data_item_mapping_test.cpp +++ b/test_package/data_item_mapping_test.cpp @@ -102,6 +102,7 @@ class DataItemMappingTest : public testing::Test inline DataSetEntry operator"" _E(const char *c, std::size_t) { return DataSetEntry(c); } +///@test Test the creation of a simple event data item getters and setters. TEST_F(DataItemMappingTest, SimpleEvent) { Properties props {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}; @@ -123,6 +124,7 @@ TEST_F(DataItemMappingTest, SimpleEvent) ASSERT_EQ("READY", event->getValue()); } +///@test Tests unavailable data item getters and setters. TEST_F(DataItemMappingTest, SimpleUnavailableEvent) { Properties props {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}; @@ -143,6 +145,7 @@ TEST_F(DataItemMappingTest, SimpleUnavailableEvent) ASSERT_TRUE(event->isUnavailable()); } +///@test Tests two simple event data items. TEST_F(DataItemMappingTest, TwoSimpleEvents) { Properties props {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}; @@ -173,6 +176,7 @@ TEST_F(DataItemMappingTest, TwoSimpleEvents) } } +///@test Tests message data item getters and setters. TEST_F(DataItemMappingTest, Message) { Properties props {{"id", "a"s}, {"type", "MESSAGE"s}, {"category", "EVENT"s}}; @@ -196,6 +200,7 @@ TEST_F(DataItemMappingTest, Message) } } +///@test Tests sample data item getters and setters. TEST_F(DataItemMappingTest, SampleTest) { auto di = makeDataItem( @@ -215,6 +220,7 @@ TEST_F(DataItemMappingTest, SampleTest) ASSERT_EQ(1.23456, sample->getValue()); } +///@test Tests the formatting of sample data items. TEST_F(DataItemMappingTest, SampleTestFormatIssue) { makeDataItem( @@ -229,6 +235,7 @@ TEST_F(DataItemMappingTest, SampleTestFormatIssue) ASSERT_TRUE(sample->isUnavailable()); } +///@test Tests data items represented as time series. TEST_F(DataItemMappingTest, SampleTimeseries) { auto di = makeDataItem({{"id", "a"s}, @@ -250,6 +257,7 @@ TEST_F(DataItemMappingTest, SampleTimeseries) ASSERT_EQ(100.0, sample->get("sampleRate")); } +///@test Tests sample data items with reset trigger attributes. TEST_F(DataItemMappingTest, SampleResetTrigger) { auto di = makeDataItem({{"id", "a"s}, @@ -271,6 +279,7 @@ TEST_F(DataItemMappingTest, SampleResetTrigger) ASSERT_EQ("MANUAL", sample->get("resetTriggered")); } +///@test Tests condition data items getters and setters. TEST_F(DataItemMappingTest, Condition) { auto di = makeDataItem({{"id", "a"s}, {"type", "POSITION"s}, {"category", "CONDITION"s}}); @@ -292,6 +301,7 @@ TEST_F(DataItemMappingTest, Condition) ASSERT_EQ("Fault", cond->getName()); } +///@test Tests normal condition data items. TEST_F(DataItemMappingTest, ConditionNormal) { auto di = makeDataItem({{"id", "a"s}, {"type", "POSITION"s}, {"category", "CONDITION"s}}); @@ -313,6 +323,7 @@ TEST_F(DataItemMappingTest, ConditionNormal) ASSERT_EQ("Normal", cond->getName()); } +///@test Tests normal condition data items with observations that are partially defined. TEST_F(DataItemMappingTest, ConditionNormalPartial) { auto di = makeDataItem({{"id", "a"s}, {"type", "POSITION"s}, {"category", "CONDITION"s}}); @@ -334,6 +345,7 @@ TEST_F(DataItemMappingTest, ConditionNormalPartial) ASSERT_EQ("Normal", cond->getName()); } +///@test Tests data set getters and setters. TEST_F(DataItemMappingTest, DataSet) { auto di = makeDataItem({{"id", "a"s}, @@ -359,6 +371,7 @@ TEST_F(DataItemMappingTest, DataSet) ASSERT_EQ("abc", get(ds.find("c"_E)->m_value)); } +///@test Tests table getters and setters. TEST_F(DataItemMappingTest, Table) { auto di = makeDataItem( @@ -393,6 +406,7 @@ TEST_F(DataItemMappingTest, Table) ASSERT_EQ("def", get(c.find("y"_E)->m_value)); } +///@test Tests data sets' reset triggered attribute. TEST_F(DataItemMappingTest, DataSetResetTriggered) { makeDataItem({{"id", "a"s}, @@ -414,6 +428,7 @@ TEST_F(DataItemMappingTest, DataSetResetTriggered) ASSERT_EQ(3, ds.size()); } +///@test Tests tables' reset triggered attribute. TEST_F(DataItemMappingTest, TableResetTriggered) { makeDataItem( @@ -432,6 +447,7 @@ TEST_F(DataItemMappingTest, TableResetTriggered) ASSERT_EQ(3, ds.size()); } +///@test Tests the new mapping of new tokens to data item observations. TEST_F(DataItemMappingTest, new_token_mapping_behavior) { m_mapper = make_shared(m_context, "", 2); @@ -462,6 +478,7 @@ TEST_F(DataItemMappingTest, new_token_mapping_behavior) ASSERT_EQ("code", message->get("nativeCode")); } +///@test Tests the legacy mapping of new tokens to data item observations. TEST_F(DataItemMappingTest, legacy_token_mapping_behavior) { m_mapper = make_shared(m_context, "", 1); @@ -494,6 +511,7 @@ TEST_F(DataItemMappingTest, legacy_token_mapping_behavior) ASSERT_EQ("value1", event->getValue()); } +///@test Tests that data items continue to map even after conversion error. TEST_F(DataItemMappingTest, continue_after_conversion_error) { auto ppos = makeDataItem({{"id", "a"s}, diff --git a/test_package/data_item_test.cpp b/test_package/data_item_test.cpp index 178bb1ca0..29d6eb27e 100644 --- a/test_package/data_item_test.cpp +++ b/test_package/data_item_test.cpp @@ -88,6 +88,7 @@ class DataItemTest : public testing::Test DataItemPtr m_dataItemC; }; +///@test Tests getters for data items. TEST_F(DataItemTest, Getters) { ASSERT_EQ("1", m_dataItemA->getId()); @@ -107,6 +108,7 @@ TEST_F(DataItemTest, Getters) ASSERT_EQ(1.0, m_dataItemB->get("nativeScale")); } +///@test Tests that data items have a name and source. TEST_F(DataItemTest, HasNameAndSource) { namespace di = mtconnect::device_model::data_item; @@ -140,12 +142,14 @@ TEST_F(DataItemTest, HasNameAndSource) ASSERT_EQ("DataItemTest2Source", dataItem->getPreferredName()); } +///@test Tests that data items can be recognized as samples. TEST_F(DataItemTest, IsSample) { ASSERT_TRUE(m_dataItemA->isSample()); ASSERT_FALSE(m_dataItemC->isSample()); } +///@test Test the conversion of strings to camel case. TEST_F(DataItemTest, GetCamel) { std::optional prefix; @@ -168,8 +172,10 @@ TEST_F(DataItemTest, GetCamel) ASSERT_EQ((string) "x", *prefix); } +///@test Tests conditions data items. TEST_F(DataItemTest, Condition) { ASSERT_EQ(DataItem::CONDITION, m_dataItemC->getCategory()); } +///@test Tests time series data items can be created. TEST_F(DataItemTest, TimeSeries) { { @@ -203,6 +209,7 @@ TEST_F(DataItemTest, TimeSeries) } } +///@test Test that statistic attributes for data items can be created. TEST_F(DataItemTest, Statistic) { Properties props {{"id", "1"s}, @@ -219,6 +226,7 @@ TEST_F(DataItemTest, Statistic) ASSERT_EQ("AVERAGE", d->get("statistic")); } +///@test Test that sample rate attributes for data items can be created. TEST_F(DataItemTest, SampleRate) { Properties props {{"id", "1"s}, diff --git a/test_package/data_set_test.cpp b/test_package/data_set_test.cpp index 4c2fd43c6..036e1f6c3 100644 --- a/test_package/data_set_test.cpp +++ b/test_package/data_set_test.cpp @@ -79,6 +79,7 @@ using namespace date::literals; inline DataSetEntry operator"" _E(const char *c, std::size_t) { return DataSetEntry(c); } +///@test Test the creation of a data item for a data set. TEST_F(DataSetTest, DataItem) { ASSERT_TRUE(m_dataItem1->isDataSet()); @@ -87,6 +88,7 @@ TEST_F(DataSetTest, DataItem) ASSERT_EQ("VariableDataSet", m_dataItem1->getObservationName()); } +///@test Tests the initialization of a dataset with observations. TEST_F(DataSetTest, InitialSet) { ErrorList errors; @@ -117,6 +119,7 @@ TEST_F(DataSetTest, InitialSet) ASSERT_EQ(4, get(ds2.find("d"_E)->m_value)); } +///@test Test the ability for data sets to parse simple formats. TEST_F(DataSetTest, parser_simple_formats) { DataSet s1; @@ -130,6 +133,7 @@ TEST_F(DataSetTest, parser_simple_formats) ASSERT_TRUE(s1.find("e"_E)->m_removed); } +///@test Test the ability for data sets to parse with braces. TEST_F(DataSetTest, parser_test_with_braces) { DataSet s2; @@ -138,6 +142,7 @@ TEST_F(DataSetTest, parser_test_with_braces) ASSERT_EQ(" abc 123 ", get(s2.find("abc"_E)->m_value)); } +///@test Test the ability for data sets to parse with an escaped brace. TEST_F(DataSetTest, parser_test_with_escaped_brace) { DataSet s3; @@ -146,6 +151,7 @@ TEST_F(DataSetTest, parser_test_with_escaped_brace) ASSERT_EQ(" abc } 123 ", get(s3.find("abc"_E)->m_value)); } +///@test Test the ability for data sets to parse with an escaped quote. TEST_F(DataSetTest, parser_test_with_escaped_quote) { DataSet s4; @@ -154,6 +160,7 @@ TEST_F(DataSetTest, parser_test_with_escaped_quote) ASSERT_EQ(" abc ' 123 ", get(s4.find("abc"_E)->m_value)); } +///@test Tests the interaction between the data set parser and bad data. TEST_F(DataSetTest, parser_with_bad_data) { DataSet set; @@ -163,6 +170,7 @@ TEST_F(DataSetTest, parser_with_bad_data) ASSERT_EQ(2.0, get(set.find("b"_E)->m_value)); } +///@test Tests the performance of the data set parse with a large dataset. TEST_F(DataSetTest, parser_with_big_data_set) { using namespace std::chrono; @@ -190,6 +198,7 @@ TEST_F(DataSetTest, parser_with_big_data_set) free(buffer); } +///@test Tests the interaction between the data set parser and partial number. TEST_F(DataSetTest, parser_with_partial_number) { DataSet set; @@ -201,6 +210,7 @@ TEST_F(DataSetTest, parser_with_partial_number) ASSERT_EQ(4.56, get(set.find("d"_E)->m_value)); } +///@test Tests the ability for a data set to update a single element. TEST_F(DataSetTest, UpdateOneElement) { ErrorList errors; @@ -243,6 +253,7 @@ TEST_F(DataSetTest, UpdateOneElement) ASSERT_EQ(6, get(map2.find("e"_E)->m_value)); } +///@test Tests the ability for a data set to update multiple elements. TEST_F(DataSetTest, UpdateMany) { ErrorList errors; @@ -288,6 +299,7 @@ TEST_F(DataSetTest, UpdateMany) ASSERT_EQ(9, get(map2.find("f"_E)->m_value)); } +///@test Tests the reset for a data set. TEST_F(DataSetTest, Reset) { ErrorList errors; @@ -325,6 +337,7 @@ TEST_F(DataSetTest, Reset) ASSERT_EQ((string) "hop", get(map2.find("y"_E)->m_value)); } +///@test Tests the interaction between a data set and bad data. TEST_F(DataSetTest, BadData) { ErrorList errors; @@ -351,6 +364,7 @@ TEST_F(DataSetTest, BadData) #define ASSERT_DATA_SET_ENTRY(doc, var, key, expected) \ ASSERT_XML_PATH_EQUAL(doc, "//m:" var "/m:Entry[@key='" key "']", expected) +///@test Test the data set's ability to present current data. TEST_F(DataSetTest, Current) { m_agentTestHelper->addAdapter(); @@ -416,6 +430,7 @@ TEST_F(DataSetTest, Current) } } +///@test Tests the sampling of data sets. TEST_F(DataSetTest, Sample) { m_agentTestHelper->addAdapter(); @@ -475,6 +490,7 @@ TEST_F(DataSetTest, Sample) } } +///@test Tests the retrieval of current values at a specified sequence number. TEST_F(DataSetTest, CurrentAt) { using namespace mtconnect::sink::rest_sink; @@ -558,6 +574,7 @@ TEST_F(DataSetTest, CurrentAt) } } +///@test Test the deletion of data from a data set by key. TEST_F(DataSetTest, DeleteKey) { ErrorList errors; @@ -590,6 +607,7 @@ TEST_F(DataSetTest, DeleteKey) ASSERT_TRUE(map1.find("a"_E) == map1.end()); } +///@test Tests the reset of data sets without data items. TEST_F(DataSetTest, ResetWithNoItems) { m_agentTestHelper->addAdapter(); @@ -624,6 +642,7 @@ TEST_F(DataSetTest, ResetWithNoItems) } } +///@test Tests the compression of datasets containing duplicate data items. TEST_F(DataSetTest, DuplicateCompression) { m_agentTestHelper->addAdapter(); @@ -684,6 +703,7 @@ TEST_F(DataSetTest, DuplicateCompression) } } +///@test Tests the delimiting of data set data via quotation marks. TEST_F(DataSetTest, QuoteDelimeter) { m_agentTestHelper->addAdapter(); @@ -720,6 +740,7 @@ TEST_F(DataSetTest, QuoteDelimeter) } } +///@test Tests the representation of discrete data sets. TEST_F(DataSetTest, Discrete) { m_agentTestHelper->addAdapter(); @@ -755,6 +776,7 @@ TEST_F(DataSetTest, Discrete) } } +///@test Tests the probing of data set data items. TEST_F(DataSetTest, Probe) { m_agentTestHelper->addAdapter(); @@ -767,6 +789,7 @@ TEST_F(DataSetTest, Probe) } } +///@test Tests the translation of data set information to JSON format. TEST_F(DataSetTest, JsonCurrent) { using namespace rest_sink; diff --git a/test_package/device_test.cpp b/test_package/device_test.cpp index a0a728922..37b9bbe2f 100644 --- a/test_package/device_test.cpp +++ b/test_package/device_test.cpp @@ -57,6 +57,7 @@ class DeviceTest : public testing::Test DevicePtr m_devA, m_devB; }; +///@test Tests getters for devices. TEST_F(DeviceTest, Getters) { ASSERT_EQ((string) "Device", string(m_devA->getName())); @@ -70,6 +71,7 @@ TEST_F(DeviceTest, Getters) ASSERT_EQ((string) "UnivUniqId2", m_devB->getUuid()); } +///@test Tests the description attribute for devices. TEST_F(DeviceTest, Description) { ErrorList errors; @@ -103,6 +105,7 @@ TEST_F(DeviceTest, Description) ASSERT_EQ((string) "Machine 2", descB->getValue()); } +///@test Test data items for devices. TEST_F(DeviceTest, DataItems) { ASSERT_FALSE(m_devA->getDataItems()); @@ -123,6 +126,7 @@ TEST_F(DeviceTest, DataItems) ASSERT_TRUE(data2 == items->back()); } +///@test Tests the device data item. TEST_F(DeviceTest, DeviceDataItem) { ASSERT_FALSE(m_devA->getDataItems()); @@ -145,6 +149,7 @@ TEST_F(DeviceTest, DeviceDataItem) ASSERT_TRUE(data2 == m_devA->getDeviceDataItem("DataItemTest2")); } +///@test Tests the ability to get a data item for a device. TEST_F(DeviceTest, GetDataItem) { ErrorList errors; @@ -195,6 +200,7 @@ TEST_F(DeviceTest, GetDataItem) ASSERT_TRUE(data3 == m_devA->getDeviceDataItem("by_source3")); } +///@test Tests if a topics are created for data items. TEST_F(DeviceTest, should_create_data_item_topic) { ErrorList errors; @@ -210,6 +216,7 @@ TEST_F(DeviceTest, should_create_data_item_topic) ASSERT_EQ("Availability", di->getTopicName()); } +///@test Tests if topics are created for components and data items. TEST_F(DeviceTest, should_create_component_and_data_item_topic) { ErrorList errors; @@ -239,6 +246,7 @@ TEST_F(DeviceTest, should_create_component_and_data_item_topic) ASSERT_EQ("Position.Actual[Xact]", di->getTopicName()); } +///@test tests if topics are created with composition. TEST_F(DeviceTest, should_create_topic_with_composition) { ErrorList errors; diff --git a/test_package/duplicate_filter_test.cpp b/test_package/duplicate_filter_test.cpp index 9c40401e8..9ba50398f 100644 --- a/test_package/duplicate_filter_test.cpp +++ b/test_package/duplicate_filter_test.cpp @@ -119,6 +119,7 @@ class DuplicateFilterTest : public testing::Test ComponentPtr m_component; }; +///@test Tests duplicate filtering of simple events. TEST_F(DuplicateFilterTest, test_simple_event) { makeDataItem({{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); @@ -140,6 +141,7 @@ TEST_F(DuplicateFilterTest, test_simple_event) ASSERT_EQ(1, list3.size()); } +///@test Tests duplicate filtering of simple samples. TEST_F(DuplicateFilterTest, test_simple_sample) { makeDataItem( @@ -162,6 +164,7 @@ TEST_F(DuplicateFilterTest, test_simple_sample) ASSERT_EQ(1, list3.size()); } +///@test Tests duplicate filtering minimum epsilon. TEST_F(DuplicateFilterTest, test_minimum_delta) { ErrorList errors; @@ -215,6 +218,7 @@ TEST_F(DuplicateFilterTest, test_minimum_delta) } } +///@test Tests duplicate filtering of simple conditions. TEST_F(DuplicateFilterTest, test_condition_duplicates) { auto filter = make_shared(m_context); diff --git a/test_package/embedded_ruby_test.cpp b/test_package/embedded_ruby_test.cpp index d5138fe84..c71e09982 100644 --- a/test_package/embedded_ruby_test.cpp +++ b/test_package/embedded_ruby_test.cpp @@ -137,6 +137,7 @@ namespace { std::filesystem::path m_cwd; }; + ///@test Test if embedded ruby plugins initialize. TEST_F(EmbeddedRubyTest, should_initialize) { load("should_initialize.rb"); @@ -161,6 +162,7 @@ namespace { } } + ///@test Tests if embedded ruby plugins support entities. TEST_F(EmbeddedRubyTest, should_support_entities) { using namespace std::chrono; @@ -195,6 +197,7 @@ namespace { ASSERT_EQ(1577836800s, ts.time_since_epoch()); } + ///@test Tests if data sets are supported in embedded ruby plugins. TEST_F(EmbeddedRubyTest, entity_should_support_data_sets) { using namespace std::chrono; @@ -219,6 +222,7 @@ namespace { ASSERT_NEAR(123.4, ds.get("float"), 0.000001); } + ///@test Tests if tables are supported in embedded ruby plugins. TEST_F(EmbeddedRubyTest, entity_should_support_tables) { using namespace std::chrono; @@ -251,6 +255,7 @@ namespace { ASSERT_NEAR(2.0, row2.get("float"), 0.000001); } + ///@test Tests transformations within ruby plugins. TEST_F(EmbeddedRubyTest, should_transform) { using namespace std::chrono; @@ -285,6 +290,7 @@ p $source ASSERT_EQ("READY", contract->m_observation->getValue()); } + ///@test Tests transformations within ruby plugins with sub classes. TEST_F(EmbeddedRubyTest, should_transform_with_subclass) { using namespace std::chrono; @@ -316,6 +322,7 @@ p $source ASSERT_EQ("READY", contract->m_observation->getValue()); } + ///@test Tests the creation of samples in ruby plugins. TEST_F(EmbeddedRubyTest, should_create_sample) { using namespace std::chrono; @@ -349,6 +356,7 @@ p $source ASSERT_EQ("Xact", contract->m_observation->getDataItem()->getName()); } + ///@test Tests the creation of events in ruby plugins. TEST_F(EmbeddedRubyTest, should_create_event) { using namespace std::chrono; @@ -387,6 +395,7 @@ p $source ASSERT_EQ("block", contract->m_observation->getDataItem()->getName()); } + ///@test Tests the creation of conditions in ruby plugins. TEST_F(EmbeddedRubyTest, should_create_condition) { using namespace std::chrono; @@ -438,6 +447,7 @@ p $source ASSERT_EQ(Condition::FAULT, cond->getLevel()); } + ///@test Tests the changing of data item topics in ruby plugins. TEST_F(EmbeddedRubyTest, should_change_data_item_topic) { load("should_rename_data_item_topic.rb"); diff --git a/test_package/entity_parser_test.cpp b/test_package/entity_parser_test.cpp index 1c130b87e..69cecb688 100644 --- a/test_package/entity_parser_test.cpp +++ b/test_package/entity_parser_test.cpp @@ -80,6 +80,7 @@ class EntityParserTest : public testing::Test } }; +///@test Tests the entity parser on a simple document. TEST_F(EntityParserTest, TestParseSimpleDocument) { auto fileProperty = @@ -144,6 +145,7 @@ TEST_F(EntityParserTest, TestParseSimpleDocument) ASSERT_EQ("Flat", get((*it)->getProperty("VALUE"))); } +///@test Tests the entity parser on recursive entity lists. TEST_F(EntityParserTest, TestRecursiveEntityLists) { auto root = components(); @@ -193,6 +195,7 @@ TEST_F(EntityParserTest, TestRecursiveEntityLists) ASSERT_EQ("h1", get((*sli)->getProperty("id"))); } +///@test Tests the failure of an entity parser on recursive entity lists. TEST_F(EntityParserTest, TestRecursiveEntityListFailure) { auto root = components(); @@ -219,6 +222,7 @@ TEST_F(EntityParserTest, TestRecursiveEntityListFailure) errors.front()->what()); } +///@test Tests the entity parser on entity lists with missing components. TEST_F(EntityParserTest, TestRecursiveEntityListMissingComponents) { auto root = components(); @@ -259,6 +263,7 @@ TEST_F(EntityParserTest, TestRecursiveEntityListMissingComponents) ASSERT_FALSE(sl); } +///@test Tests the entity parse on raw content. TEST_F(EntityParserTest, TestRawContent) { auto definition = @@ -292,6 +297,7 @@ TEST_F(EntityParserTest, TestRawContent) ASSERT_EQ(expected, get(entity->getProperty("RAW"))); } +///@test Test the entity parser on documents with proper line truncation. TEST_F(EntityParserTest, check_proper_line_truncation) { auto description = make_shared( diff --git a/test_package/entity_printer_test.cpp b/test_package/entity_printer_test.cpp index 558f4e8ec..c0adeba49 100644 --- a/test_package/entity_printer_test.cpp +++ b/test_package/entity_printer_test.cpp @@ -87,6 +87,7 @@ class EntityPrinterTest : public testing::Test std::unique_ptr m_writer; }; +///@test Tests the entity printer on printing a simple parsed document. TEST_F(EntityPrinterTest, TestParseSimpleDocument) { auto root = createFileArchetypeFactory(); @@ -112,6 +113,7 @@ TEST_F(EntityPrinterTest, TestParseSimpleDocument) ASSERT_EQ(doc, m_writer->getContent()); } +///@test Tests the entity printer on printing a test file archetype with a description. TEST_F(EntityPrinterTest, TestFileArchetypeWithDescription) { auto root = createFileArchetypeFactory(); @@ -138,6 +140,7 @@ TEST_F(EntityPrinterTest, TestFileArchetypeWithDescription) ASSERT_EQ(doc, m_writer->getContent()); } +///@test Tests the entity printer on recursive entity lists. TEST_F(EntityPrinterTest, TestRecursiveEntityLists) { auto component = make_shared(Requirements { @@ -185,6 +188,7 @@ TEST_F(EntityPrinterTest, TestRecursiveEntityLists) ASSERT_EQ(doc, m_writer->getContent()); } +///@test Tests the entity printer's ability to preserve element order. TEST_F(EntityPrinterTest, TestEntityOrder) { auto component = make_shared(Requirements { @@ -243,6 +247,7 @@ TEST_F(EntityPrinterTest, TestEntityOrder) ASSERT_EQ(expected, m_writer->getContent()); } +///@test Tests the entity printer on raw content. TEST_F(EntityPrinterTest, TestRawContent) { auto definition = @@ -280,6 +285,7 @@ TEST_F(EntityPrinterTest, TestRawContent) ASSERT_EQ(expected, m_writer->getContent()); } +///@test Tests if the entity printer includes hidden parameters. TEST_F(EntityPrinterTest, should_honor_include_hidden_parameter) { auto component = make_shared(Requirements { @@ -409,6 +415,7 @@ class EntityPrinterNamespaceTest : public EntityPrinterTest } }; +///@test Test the entity printer's name space removal when there are no namespaces. TEST_F(EntityPrinterNamespaceTest, test_namespace_removal_when_no_namespaces) { auto entity = createDevice(); @@ -428,6 +435,7 @@ TEST_F(EntityPrinterNamespaceTest, test_namespace_removal_when_no_namespaces) ASSERT_EQ(expected, m_writer->getContent()); } +///@test Test the entity printer's name space removal when there are namespaces. TEST_F(EntityPrinterNamespaceTest, test_namespace_removal_with_namespaces) { auto entity = createDevice(); diff --git a/test_package/entity_test.cpp b/test_package/entity_test.cpp index 974c0992e..206caf492 100644 --- a/test_package/entity_test.cpp +++ b/test_package/entity_test.cpp @@ -53,6 +53,7 @@ class EntityTest : public testing::Test void TearDown() override {} }; +///@test tests simple entity factory. TEST_F(EntityTest, TestSimpleFactory) { FactoryPtr root = make_shared(); @@ -71,6 +72,7 @@ TEST_F(EntityTest, TestSimpleFactory) ASSERT_EQ(10, get(entity->getProperty("size"))); } +///@test Tests simple two-level entity factory. TEST_F(EntityTest, TestSimpleTwoLevelFactory) { auto root = make_shared(); @@ -113,6 +115,7 @@ TEST_F(EntityTest, TestSimpleTwoLevelFactory) ASSERT_EQ("arf", get(v->getProperty("VALUE"))); } +///@test Tests the creation of a simple entity list. TEST_F(EntityTest, TestSimpleEntityList) { auto root = make_shared(); @@ -187,6 +190,7 @@ TEST_F(EntityTest, TestSimpleEntityList) ASSERT_EQ("meow", get((*it)->getProperty("VALUE"))); } +///@test Tests the error from entities with missing properties. TEST_F(EntityTest, MissingProperty) { FactoryPtr root = make_shared(); @@ -205,6 +209,7 @@ TEST_F(EntityTest, MissingProperty) string(errors.front()->what())); } +///@test Tests entites with missing optional properties. TEST_F(EntityTest, MissingOptionalProperty) { FactoryPtr root = make_shared(); @@ -225,6 +230,7 @@ TEST_F(EntityTest, MissingOptionalProperty) ASSERT_EQ(0, errors.size()); } +///@test Tests the error from entities with unexpected properties. TEST_F(EntityTest, UnexpectedProperty) { FactoryPtr root = make_shared(); @@ -243,6 +249,7 @@ TEST_F(EntityTest, UnexpectedProperty) string(errors.front()->what())); } +///@test Tests the listing of any entites. TEST_F(EntityTest, EntityListAnyEntities) { auto root = make_shared(); @@ -321,6 +328,7 @@ TEST_F(EntityTest, EntityListAnyEntities) ASSERT_EQ("meow", get((*it)->getProperty("VALUE"))); } +///@test Tests integer conversions for entities. TEST_F(EntityTest, TestRequirementIntegerConversions) { Value v("123"s); @@ -367,6 +375,7 @@ TEST_F(EntityTest, TestRequirementIntegerConversions) ASSERT_THROW(r1.convertType(v), PropertyError); } +///@test Tests string conversions for entities. TEST_F(EntityTest, TestRequirementStringConversion) { Value v(1234567890_i64); @@ -391,6 +400,7 @@ TEST_F(EntityTest, TestRequirementStringConversion) ASSERT_FALSE(r1.convertType(v)); } +///@test Tests double conversions for entities. TEST_F(EntityTest, TestRequirementDoubleConversions) { Value v("123.24"s); @@ -428,6 +438,7 @@ TEST_F(EntityTest, TestRequirementDoubleConversions) ASSERT_EQ(123.24, get(v)[0]); } +///@test Tests vector conversions for entities. TEST_F(EntityTest, TestRequirementVectorConversions) { Value v("1.234 3.456 6.7889"s); @@ -464,6 +475,7 @@ TEST_F(EntityTest, TestRequirementVectorConversions) EXPECT_THROW(r6.convertType(v), PropertyError); } +///@test Tests upper case string conversions for entities. TEST_F(EntityTest, TestRequirementUpperCaseStringConversion) { Value v("hello kitty"s); @@ -473,6 +485,7 @@ TEST_F(EntityTest, TestRequirementUpperCaseStringConversion) ASSERT_EQ("HELLO KITTY", get(v)); } +///@test Tests controlled vocabulary for entities. TEST_F(EntityTest, TestControlledVocabulary) { FactoryPtr root = make_shared(); @@ -501,6 +514,7 @@ TEST_F(EntityTest, TestControlledVocabulary) string(errors.front()->what())); } +///@test Tests error from entity requirements. TEST_F(EntityTest, entity_list_requirements_need_with_at_least_one_requiremenet) { auto ref1 = make_shared(Requirements {{"id", true}, {"name", false}, {"type", true}}); @@ -544,6 +558,7 @@ TEST_F(EntityTest, entity_list_requirements_need_with_at_least_one_requiremenet) ASSERT_TRUE(bad2); } +///@test Tests equality comparison between entities. TEST_F(EntityTest, entities_should_compare_for_equality) { auto root = make_shared(); @@ -578,6 +593,7 @@ TEST_F(EntityTest, entities_should_compare_for_equality) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests inequality comparison between entities. TEST_F(EntityTest, entities_should_compare_for_inequality) { auto root = make_shared(); @@ -612,6 +628,7 @@ TEST_F(EntityTest, entities_should_compare_for_inequality) ASSERT_NE(*(v1.get()), *(v2.get())); } +///@test Tests equality comparison with an entities list. TEST_F(EntityTest, entities_should_compare_for_equality_with_entity_list) { auto root = make_shared(); @@ -658,6 +675,7 @@ TEST_F(EntityTest, entities_should_compare_for_equality_with_entity_list) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests inequality comparison with an entities list. TEST_F(EntityTest, entities_should_compare_for_inequality_with_entity_list) { auto root = make_shared(); @@ -704,6 +722,7 @@ TEST_F(EntityTest, entities_should_compare_for_inequality_with_entity_list) ASSERT_NE(*(v1.get()), *(v2.get())); } +///@test Tests the merging of entites. TEST_F(EntityTest, entities_should_merge) { auto root = make_shared(); @@ -747,6 +766,7 @@ TEST_F(EntityTest, entities_should_merge) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests the merging of entites with entity lists. TEST_F(EntityTest, entities_should_merge_entity_list) { auto root = make_shared(); @@ -803,6 +823,7 @@ TEST_F(EntityTest, entities_should_merge_entity_list) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Test the merging of entities and entity lists as new data items. TEST_F(EntityTest, entities_should_merge_entity_list_with_new_item) { auto root = make_shared(); @@ -872,6 +893,7 @@ TEST_F(EntityTest, entities_should_merge_entity_list_with_new_item) EXPECT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests the removal of missing entities from entity lists. TEST_F(EntityTest, should_remove_missing_entities) { auto root = make_shared(); @@ -935,6 +957,7 @@ TEST_F(EntityTest, should_remove_missing_entities) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests ignoring certain entities with specific ids. TEST_F(EntityTest, should_ignore_certain_entities_with_specific_ids) { auto root = make_shared(); @@ -998,6 +1021,7 @@ TEST_F(EntityTest, should_ignore_certain_entities_with_specific_ids) ASSERT_NE(*(v1.get()), *(v2.get())); } +///@test Tests ignoring certain entities with changes and removals. TEST_F(EntityTest, should_ignore_certain_entities_with_changes_and_removals) { auto root = make_shared(); @@ -1062,4 +1086,5 @@ TEST_F(EntityTest, should_ignore_certain_entities_with_changes_and_removals) ASSERT_EQ(*(v1.get()), *(v2.get())); } +///@test Tests the merging of entities and entity lists without identity (skipped). TEST_F(EntityTest, entities_should_merge_entity_lists_without_identity) { GTEST_SKIP(); } diff --git a/test_package/file_asset_test.cpp b/test_package/file_asset_test.cpp index a2d57c932..b7288a0ed 100644 --- a/test_package/file_asset_test.cpp +++ b/test_package/file_asset_test.cpp @@ -67,6 +67,7 @@ class FileAssetTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +///@test Tests minimal archetype for file assets. TEST_F(FileAssetTest, TestMinmalArchetype) { const auto doc = @@ -116,6 +117,7 @@ TEST_F(FileAssetTest, TestMinmalArchetype) ASSERT_EQ(content, doc); } +///@test Tests minimal file assets. TEST_F(FileAssetTest, TestMinmalFile) { const auto doc = diff --git a/test_package/file_cache_test.cpp b/test_package/file_cache_test.cpp index 6d453f781..26d699107 100644 --- a/test_package/file_cache_test.cpp +++ b/test_package/file_cache_test.cpp @@ -57,6 +57,7 @@ class FileCacheTest : public testing::Test unique_ptr m_cache; }; +///@test Tests finding files within the file cache. TEST_F(FileCacheTest, FindFiles) { string uri("/schemas"); @@ -70,6 +71,7 @@ TEST_F(FileCacheTest, FindFiles) EXPECT_EQ("text/xml", file->m_mimeType); } +///@test Tests accessign the fav icon. TEST_F(FileCacheTest, IconMimeType) { // Register a file with the agent. @@ -80,6 +82,7 @@ TEST_F(FileCacheTest, IconMimeType) EXPECT_EQ("image/x-icon", file->m_mimeType); } +///@test Tests that large files are not cached. TEST_F(FileCacheTest, verify_large_files_are_not_cached) { // Make a cache that can only hold 1024 byte files @@ -100,6 +103,7 @@ TEST_F(FileCacheTest, verify_large_files_are_not_cached) ASSERT_TRUE(css->m_cached); } +///@test Tests that the base directory redirects. TEST_F(FileCacheTest, base_directory_should_redirect) { m_cache->addDirectory("/schemas", TEST_RESOURCE_DIR "/schemas", "none.xsd"); @@ -116,6 +120,7 @@ TEST_F(FileCacheTest, base_directory_should_redirect) ASSERT_TRUE(boost::starts_with(std::string(file->m_buffer), "")); } +///@test Tests that the file cache compresses files. TEST_F(FileCacheTest, file_cache_should_compress_file) { namespace fs = std::filesystem; @@ -151,6 +156,7 @@ TEST_F(FileCacheTest, file_cache_should_compress_file) } } +///@test Tests that file compression by the file cache is asynchronous. TEST_F(FileCacheTest, file_cache_should_compress_file_async) { namespace fs = std::filesystem; @@ -201,6 +207,7 @@ static inline void touch(const std::filesystem::path &file) fs::last_write_time(file, now); } +///@test Tests that the file cache recompresses if gzip is older than the file. TEST_F(FileCacheTest, file_cache_should_recompress_if_gzip_older_than_file) { namespace fs = std::filesystem; diff --git a/test_package/globals_test.cpp b/test_package/globals_test.cpp index 23c423393..4ba0d9869 100644 --- a/test_package/globals_test.cpp +++ b/test_package/globals_test.cpp @@ -34,6 +34,7 @@ int main(int argc, char *argv[]) return RUN_ALL_TESTS(); } +///@test Test the conversion of integers to strings. TEST(GlobalsTest, IntToString) { ASSERT_EQ((string) "1234", to_string(1234)); @@ -42,6 +43,7 @@ TEST(GlobalsTest, IntToString) ASSERT_EQ((string) "1", to_string(1)); } +///@test Test the conversion of floats to strings. TEST(GlobalsTest, FloatToString) { ASSERT_EQ((string) "1.234", format(1.234)); @@ -50,6 +52,7 @@ TEST(GlobalsTest, FloatToString) ASSERT_EQ((string) "1", format(1.0)); } +///@test Test the conversion of string to upper case strings. TEST(GlobalsTest, ToUpperCase) { string lower = "abcDef"; @@ -62,6 +65,7 @@ TEST(GlobalsTest, ToUpperCase) ASSERT_EQ((string) "QWERTY.ASDF|", toUpperCase(lower)); } +///@test Tests the determination of whether a string is a non-negative integer. TEST(GlobalsTest, IsNonNegativeInteger) { ASSERT_TRUE(isNonNegativeInteger("12345")); @@ -72,6 +76,7 @@ TEST(GlobalsTest, IsNonNegativeInteger) ASSERT_TRUE(!isNonNegativeInteger("123.45")); } +///@test Tests time representation. TEST(GlobalsTest, Time) { auto time1 = getCurrentTime(GMT); @@ -99,6 +104,7 @@ TEST(GlobalsTest, Time) ASSERT_TRUE(time7 < time9); } +///@test Tests illegal character identification and replacement. TEST(GlobalsTest, IllegalCharacters) { string before1("Don't Change Me"), after1("Don't Change Me"); @@ -114,6 +120,7 @@ TEST(GlobalsTest, IllegalCharacters) ASSERT_EQ(before3, after3); } +///@test Tests getting the current time. TEST(GlobalsTest, GetCurrentTime) { auto gmt = getCurrentTime(GMT); @@ -140,6 +147,7 @@ TEST(GlobalsTest, GetCurrentTime) ASSERT_EQ(8, n); } +///@test Tests getting the current time from string timestamps. TEST(GlobalsTest, GetCurrentTime2) { // Build a known system time point @@ -173,6 +181,7 @@ TEST(GlobalsTest, GetCurrentTime2) ASSERT_EQ(string("Thu, 01 Jan 1970 00:00:10 GMT"), humRead); } +///@test Tests the parsing of microsecond resolution timestamps. TEST(GlobalsTest, ParseTimeMicro) { // This time is 123456 microseconds after the epoch @@ -180,6 +189,7 @@ TEST(GlobalsTest, ParseTimeMicro) ASSERT_EQ(uint64_t {123456}, v); } +///@test Tests adding namespaces to data items. TEST(GlobalsTest, AddNamespace) { auto result = addNamespace("//Device//Foo", "m"); @@ -201,6 +211,7 @@ TEST(GlobalsTest, AddNamespace) ASSERT_EQ(string("//m:Device/m:DataItems/"), result); } +///@test Tests parsing of millisecond resolution time stamps. TEST(GlobalsTest, ParseTimeMilli) { string v = "2012-11-20T12:33:22.123456"; @@ -213,4 +224,5 @@ TEST(GlobalsTest, ParseTimeMilli) ASSERT_TRUE(1353414802123000LL == time); } +///@test Test the conversion of 64-bit integers to strings. TEST(GlobalsTest, Int64ToString) { ASSERT_EQ((string) "8805345009", to_string(8805345009ULL)); } diff --git a/test_package/http_server_test.cpp b/test_package/http_server_test.cpp index 07d69fb67..1acc54613 100644 --- a/test_package/http_server_test.cpp +++ b/test_package/http_server_test.cpp @@ -324,6 +324,7 @@ class RestServiceTest : public testing::Test unique_ptr m_client; }; +///@test Tests simple request and response from the http server. TEST_F(RestServiceTest, simple_request_response) { weak_ptr savedSession; @@ -362,6 +363,7 @@ TEST_F(RestServiceTest, simple_request_response) ASSERT_TRUE(savedSession.expired()); } +///@test Tests request and response from the http server with query parameters. TEST_F(RestServiceTest, request_response_with_query_parameters) { auto handler = [&](SessionPtr session, RequestPtr request) -> bool { @@ -397,6 +399,7 @@ TEST_F(RestServiceTest, request_response_with_query_parameters) EXPECT_EQ(200, m_client->m_status); } +///@test Tests sending a put requests when it is not allowed. TEST_F(RestServiceTest, request_put_when_put_not_allowed) { auto probe = [&](SessionPtr session, RequestPtr request) -> bool { @@ -418,6 +421,7 @@ TEST_F(RestServiceTest, request_put_when_put_not_allowed) m_client->m_result); } +///@test Tests sending a put requests when it is allowed. TEST_F(RestServiceTest, request_put_when_put_allowed) { auto handler = [&](SessionPtr session, RequestPtr request) -> bool { @@ -442,6 +446,7 @@ TEST_F(RestServiceTest, request_put_when_put_allowed) EXPECT_EQ("Put ok", m_client->m_result); } +///@test Tests sending a put requests when it is not allowed from sender's IP address. TEST_F(RestServiceTest, request_put_when_put_not_allowed_from_ip_address) { weak_ptr session; @@ -463,6 +468,7 @@ TEST_F(RestServiceTest, request_put_when_put_not_allowed_from_ip_address) EXPECT_EQ("PUT, POST, and DELETE are not allowed from 127.0.0.1", m_client->m_result); } +///@test Tests sending a put requests when it is allowed from sender's IP address. TEST_F(RestServiceTest, request_put_when_put_allowed_from_ip_address) { auto handler = [&](SessionPtr session, RequestPtr request) -> bool { @@ -487,6 +493,7 @@ TEST_F(RestServiceTest, request_put_when_put_allowed_from_ip_address) EXPECT_EQ("Put ok", m_client->m_result); } +///@test Tests sending a response with a closed connection. TEST_F(RestServiceTest, request_with_connect_close) { weak_ptr savedSession; @@ -516,6 +523,7 @@ TEST_F(RestServiceTest, request_with_connect_close) EXPECT_FALSE(savedSession.lock()); } +///@test Tests putting content to the server. TEST_F(RestServiceTest, put_content_to_server) { string body; @@ -538,6 +546,7 @@ TEST_F(RestServiceTest, put_content_to_server) ASSERT_EQ("Body Content", body); } +///@test Tests putting content to the server with put values. TEST_F(RestServiceTest, put_content_with_put_values) { string body, ct; @@ -565,6 +574,7 @@ TEST_F(RestServiceTest, put_content_with_put_values) ASSERT_EQ("application/x-www-form-urlencoded", ct); } +///@test Tests streaming HTTP responses. TEST_F(RestServiceTest, streaming_response) { struct context @@ -648,6 +658,7 @@ TEST_F(RestServiceTest, streaming_response) ; } +///@test Tests additional header fields in HTTP requests. TEST_F(RestServiceTest, additional_header_fields) { m_server->setHttpHeaders({"Access-Control-Allow-Origin:*", "Origin:https://foo.example"}); @@ -682,6 +693,7 @@ const string KeyFile {TEST_RESOURCE_DIR "/user.key"}; const string DhFile {TEST_RESOURCE_DIR "/dh2048.pem"}; const string RootCertFile(TEST_RESOURCE_DIR "/rootca.crt"); +///@test Tests failure when only TLS is allowed. TEST_F(RestServiceTest, failure_when_tls_only) { using namespace mtconnect::configuration; diff --git a/test_package/image_file_test.cpp b/test_package/image_file_test.cpp index eca9fa5e8..052e4ce28 100644 --- a/test_package/image_file_test.cpp +++ b/test_package/image_file_test.cpp @@ -63,6 +63,7 @@ class ImageFileTest : public testing::Test std::unique_ptr m_agentTestHelper; }; +///@test Tests parsing configuration with an image file. TEST_F(ImageFileTest, should_parse_configuration_with_image_file) { ASSERT_NE(nullptr, m_device); @@ -91,6 +92,7 @@ TEST_F(ImageFileTest, should_parse_configuration_with_image_file) #define DEVICE_IMAGE_FILE_PATH_1 DEVICE_CONFIGURATION_PATH "/m:ImageFile[@id='fif']" #define DEVICE_IMAGE_FILE_PATH_2 DEVICE_CONFIGURATION_PATH "/m:ImageFile[@id='bif']" +///@test Tests printing configuration with an image file. TEST_F(ImageFileTest, should_print_configuration_with_image_file) { { @@ -110,6 +112,7 @@ TEST_F(ImageFileTest, should_print_configuration_with_image_file) } } +///@test Tests printing configuration with an image file in JSON. TEST_F(ImageFileTest, should_print_configuration_with_image_file_in_json) { { @@ -139,6 +142,7 @@ TEST_F(ImageFileTest, should_print_configuration_with_image_file_in_json) } } +///@test Tests printing configuration with an image file in JSON v2. TEST_F(ImageFileTest, should_print_configuration_with_image_file_in_json_v2) { m_agentTestHelper->createAgent("/samples/solid_model.xml", 8, 4, "2.2", 25, false, false, diff --git a/test_package/json_parser_test.cpp b/test_package/json_parser_test.cpp index 47bf5f223..2af13efd6 100644 --- a/test_package/json_parser_test.cpp +++ b/test_package/json_parser_test.cpp @@ -79,6 +79,7 @@ class JsonParserTest : public testing::Test } }; +///@test Test the parsing of simple documents by the JSON parser. TEST_F(JsonParserTest, TestParseSimpleDocument) { auto fileProperty = @@ -146,6 +147,7 @@ TEST_F(JsonParserTest, TestParseSimpleDocument) ASSERT_EQ("Flat", get((*it)->getProperty("VALUE"))); } +///@test Tests the parsing of recursive entity lists by the JSON parser. TEST_F(JsonParserTest, TestRecursiveEntityLists) { auto root = components(); @@ -197,6 +199,7 @@ TEST_F(JsonParserTest, TestRecursiveEntityLists) ASSERT_EQ("h1", get((*sli)->getProperty("id"))); } +///@test Tests the error returned by failing to parse recursive entity lists with the JSON parser. TEST_F(JsonParserTest, TestRecursiveEntityListFailure) { auto root = components(); @@ -225,6 +228,7 @@ TEST_F(JsonParserTest, TestRecursiveEntityListFailure) errors.front()->what()); } +///@test Tests the error returned by failing to parse entity lists with missing components with the JSON parser. TEST_F(JsonParserTest, TestRecursiveEntityListMissingComponents) { auto root = components(); @@ -266,6 +270,7 @@ TEST_F(JsonParserTest, TestRecursiveEntityListMissingComponents) ASSERT_FALSE(sl); } +///@test Tests the parsing of raw content with the JSON parser. TEST_F(JsonParserTest, TestRawContent) { auto definition = diff --git a/test_package/json_printer_asset_test.cpp b/test_package/json_printer_asset_test.cpp index b58be6e8b..332b375b3 100644 --- a/test_package/json_printer_asset_test.cpp +++ b/test_package/json_printer_asset_test.cpp @@ -91,6 +91,7 @@ class JsonPrinterAssetTest : public testing::Test std::unique_ptr m_parser; }; +///@test Tests printing the asset header using the json printer. TEST_F(JsonPrinterAssetTest, AssetHeader) { AssetList asset; @@ -104,6 +105,7 @@ TEST_F(JsonPrinterAssetTest, AssetHeader) ASSERT_EQ(10, jdoc.at("/MTConnectAssets/Header/assetCount"_json_pointer).get()); } +///@test Tests printing cutting tools using the json printer. TEST_F(JsonPrinterAssetTest, CuttingTool) { auto xml = getFile("asset1.xml"); @@ -133,6 +135,7 @@ TEST_F(JsonPrinterAssetTest, CuttingTool) cuttingTool.at("/CuttingTool/Description"_json_pointer).get()); } +///@test Tests printing the cutting tool life cycle using the json printer. TEST_F(JsonPrinterAssetTest, CuttingToolLifeCycle) { auto xml = getFile("asset1.xml"); @@ -172,6 +175,7 @@ TEST_F(JsonPrinterAssetTest, CuttingToolLifeCycle) ASSERT_EQ(222.0, feed.at("/value"_json_pointer).get()); } +///@test Tests printing cutting measurements using the json printer. TEST_F(JsonPrinterAssetTest, CuttingMeasurements) { auto xml = getFile("asset1.xml"); @@ -204,6 +208,7 @@ TEST_F(JsonPrinterAssetTest, CuttingMeasurements) ASSERT_EQ(120.65, length.at("/BodyLengthMax/value"_json_pointer).get()); } +///@test Tests printing cutting items using the json printer. TEST_F(JsonPrinterAssetTest, CuttingItem) { auto xml = getFile("asset1.xml"); @@ -242,6 +247,7 @@ TEST_F(JsonPrinterAssetTest, CuttingItem) ASSERT_EQ(0.8, measurements.at("/3/CornerRadius/value"_json_pointer).get()); } +///@test Tests printing the cutting tool archetype using the json printer. TEST_F(JsonPrinterAssetTest, CuttingToolArchitype) { auto xml = getFile("cutting_tool_archetype.xml"); @@ -262,6 +268,7 @@ TEST_F(JsonPrinterAssetTest, CuttingToolArchitype) ASSERT_EQ(string("Some Express..."), def.at("/value"_json_pointer).get()); } +///@test Tests the json_printer_v2 on multiple assets. TEST_F(JsonPrinterAssetTest, json_printer_version_2_with_multiple_assets) { m_printer = std::make_unique(2, true); diff --git a/test_package/json_printer_error_test.cpp b/test_package/json_printer_error_test.cpp index 147ce7967..56e095ba9 100644 --- a/test_package/json_printer_error_test.cpp +++ b/test_package/json_printer_error_test.cpp @@ -54,6 +54,7 @@ class JsonPrinterErrorTest : public testing::Test std::unique_ptr m_printer; }; +/// @test Tests JSON printer error. TEST_F(JsonPrinterErrorTest, PrintError) { auto doc = m_printer->printError(12345u, 1024u, 56u, "BAD_BAD", "Never do that again"); diff --git a/test_package/json_printer_probe_test.cpp b/test_package/json_printer_probe_test.cpp index 064c757f8..0595d01ce 100644 --- a/test_package/json_printer_probe_test.cpp +++ b/test_package/json_printer_probe_test.cpp @@ -82,6 +82,7 @@ class JsonPrinterProbeTest : public testing::Test std::unique_ptr m_xmlPrinter; }; +///@test Tests the JSON printer on a device root probe. TEST_F(JsonPrinterProbeTest, DeviceRootAndDescription) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -115,6 +116,7 @@ TEST_F(JsonPrinterProbeTest, DeviceRootAndDescription) device2.at("/Description/value"_json_pointer).get()); } +///@test Tests the JSON printer on probing top level data items. TEST_F(JsonPrinterProbeTest, TopLevelDataItems) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -148,6 +150,7 @@ TEST_F(JsonPrinterProbeTest, TopLevelDataItems) ASSERT_EQ(string("f2df7550"), remove.at("/DataItem/id"_json_pointer).get()); } +///@test Tests the JSON printer on probing sub components. TEST_F(JsonPrinterProbeTest, SubComponents) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -187,6 +190,7 @@ TEST_F(JsonPrinterProbeTest, SubComponents) ASSERT_EQ(string("ACTUAL"), ss.at("/subType"_json_pointer).get()); } +///@test Tests the JSON printer on probing data items constraints. TEST_F(JsonPrinterProbeTest, DataItemConstraints) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -217,6 +221,7 @@ TEST_F(JsonPrinterProbeTest, DataItemConstraints) ASSERT_EQ(7000.0, max.get()); } +///@test Tests the JSON printer on probing data item sources. TEST_F(JsonPrinterProbeTest, DataItemSource) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -233,6 +238,7 @@ TEST_F(JsonPrinterProbeTest, DataItemSource) ASSERT_EQ(string("taa7a0f0"), amp.at("/Source/dataItemId"_json_pointer).get()); } +///@test Tests the JSON printer on probing initial values. TEST_F(JsonPrinterProbeTest, InitialValue) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -247,6 +253,7 @@ TEST_F(JsonPrinterProbeTest, InitialValue) ASSERT_EQ(1.0, count.at("/DataItem/InitialValue"_json_pointer).get()); } +///@test Tests the JSON printer on probing data item filters. TEST_F(JsonPrinterProbeTest, DataItemFilters) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -276,6 +283,7 @@ TEST_F(JsonPrinterProbeTest, DataItemFilters) ASSERT_EQ(10.0, filter2.at("/Filter/value"_json_pointer).get()); } +///@test Tests the JSON printer on probing compositions. TEST_F(JsonPrinterProbeTest, Composition) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -296,6 +304,7 @@ TEST_F(JsonPrinterProbeTest, Composition) ASSERT_EQ(string("a7973930"), comp2.at("/id"_json_pointer).get()); } +///@test Tests the JSON printer on probing configurations. TEST_F(JsonPrinterProbeTest, Configuration) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -318,6 +327,7 @@ TEST_F(JsonPrinterProbeTest, Configuration) config.at("/Channels/0/Channel/CalibrationDate"_json_pointer).get()); } +///@test Tests the JSON printer on probing the MTConnect versions. TEST_F(JsonPrinterProbeTest, PrintDeviceMTConnectVersion) { auto doc = m_printer->printProbe(123, 9999, 1, 1024, 10, m_devices); @@ -328,6 +338,7 @@ TEST_F(JsonPrinterProbeTest, PrintDeviceMTConnectVersion) ASSERT_EQ(string("1.7"), device.at("/mtconnectVersion"_json_pointer).get()); } +///@test Tests the JSON printer on probing data items relationships. TEST_F(JsonPrinterProbeTest, PrintDataItemRelationships) { auto server = std::make_unique(m_agentTestHelper->m_ioContext); @@ -373,6 +384,7 @@ TEST_F(JsonPrinterProbeTest, PrintDataItemRelationships) ASSERT_EQ(string("xlc"), dir3.at("/DataItemRelationship/idRef"_json_pointer)); } +///@test Tests the JSON printer on probing MTConnect version 2 with multiple devices. TEST_F(JsonPrinterProbeTest, version_2_with_multiple_devices) { m_printer = std::make_unique(2, true);