diff --git a/CMakeLists.txt b/CMakeLists.txt index fe64192cb..587d290e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,16 @@ cmake_minimum_required(VERSION 3.10) cmake_policy(VERSION 3.10...3.20) + +# Set CMAKE_BUILD_TYPE to Release by default. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + ############################################################################### # Project ############################################################################### diff --git a/src/cpp/database/database.cpp b/src/cpp/database/database.cpp index f26e28fda..3fa01daa0 100644 --- a/src/cpp/database/database.cpp +++ b/src/cpp/database/database.cpp @@ -1165,85 +1165,122 @@ void Database::link_participant_with_process_nts( } const std::shared_ptr Database::get_entity( - const EntityId& entity_id) const + const EntityId& entity_id, + const EntityKind entity_kind /* = EntityKind::INVALID */) const { std::shared_lock lock(mutex_); /* Iterate over all the collections looking for the entity */ - for (const auto& host_it : hosts_) + if (EntityKind::INVALID == entity_kind || EntityKind::HOST == entity_kind) { - if (host_it.second->id == entity_id) + for (const auto& host_it : hosts_) { - return host_it.second; + if (host_it.second->id == entity_id) + { + return host_it.second; + } } } - for (const auto& process_it : processes_) + + if (EntityKind::INVALID == entity_kind || EntityKind::PROCESS == entity_kind) { - if (process_it.second->id == entity_id) + for (const auto& process_it : processes_) { - return process_it.second; + if (process_it.second->id == entity_id) + { + return process_it.second; + } } } - for (const auto& user_it : users_) + + if (EntityKind::INVALID == entity_kind || EntityKind::USER == entity_kind) { - if (user_it.second->id == entity_id) + for (const auto& user_it : users_) { - return user_it.second; + if (user_it.second->id == entity_id) + { + return user_it.second; + } } } - for (const auto& domain_it : domains_) + + if (EntityKind::INVALID == entity_kind || EntityKind::DOMAIN == entity_kind) { - if (domain_it.second->id == entity_id) + for (const auto& domain_it : domains_) { - return domain_it.second; + if (domain_it.second->id == entity_id) + { + return domain_it.second; + } } } - for (const auto& domain_it : topics_) + + if (EntityKind::INVALID == entity_kind || EntityKind::TOPIC == entity_kind) { - for (const auto& topic_it : domain_it.second) + for (const auto& domain_it : topics_) { - if (topic_it.second->id == entity_id) + for (const auto& topic_it : domain_it.second) { - return topic_it.second; + if (topic_it.second->id == entity_id) + { + return topic_it.second; + } } } } - for (const auto& domain_it : participants_) + + if (EntityKind::INVALID == entity_kind || EntityKind::PARTICIPANT == entity_kind) { - for (const auto& participant_it : domain_it.second) + for (const auto& domain_it : participants_) { - if (participant_it.second->id == entity_id) + for (const auto& participant_it : domain_it.second) { - return participant_it.second; + if (participant_it.second->id == entity_id) + { + return participant_it.second; + } } } } - for (const auto& domain_it : datareaders_) + + if (EntityKind::INVALID == entity_kind || EntityKind::DATAREADER == entity_kind) { - for (const auto& datareader_it : domain_it.second) + for (const auto& domain_it : datareaders_) { - if (datareader_it.second->id == entity_id) + for (const auto& datareader_it : domain_it.second) { - return datareader_it.second; + if (datareader_it.second->id == entity_id) + { + return datareader_it.second; + } } } } - for (const auto& domain_it : datawriters_) + + if (EntityKind::INVALID == entity_kind || EntityKind::DATAWRITER == entity_kind) { - for (const auto& datawriter_it : domain_it.second) + for (const auto& domain_it : datawriters_) { - if (datawriter_it.second->id == entity_id) + for (const auto& datawriter_it : domain_it.second) { - return datawriter_it.second; + if (datawriter_it.second->id == entity_id) + { + return datawriter_it.second; + } } } } - for (const auto& locator_it : locators_) + + if (EntityKind::INVALID == entity_kind || EntityKind::LOCATOR == entity_kind) { - if (locator_it.second->id == entity_id) + for (const auto& locator_it : locators_) { - return locator_it.second; + if (locator_it.second->id == entity_id) + { + return locator_it.second; + } } } + /* The entity has not been found */ throw BadParameter("Database does not contain an entity with ID " + entity_id.value()); } @@ -1458,8 +1495,63 @@ std::vector Database::select( throw BadParameter("Final timestamp must be strictly greater than the origin timestamp"); } - auto source_entity = get_entity(entity_id_source); - auto target_entity = get_entity(entity_id_target); + std::shared_ptr source_entity; + std::shared_ptr target_entity; + + for (auto kinds : StatisticsBackend::get_data_supported_entity_kinds(data_type)) + { + try + { + // If the entity has already been found, the kind must be checked. + // If the kind is the same as the one needed, continue looking for the target. + // If it is not, this pair of kinds is not correct so the search continues to the next pair. + if (!source_entity) + { + source_entity = get_entity(entity_id_source, kinds.first); + } + else + { + // There are no possibility with the current kinds to arrive to this branch + assert(source_entity->kind == kinds.first); + // If in the future new kinds are added that could use this branch, use this code + // if (source_entity->kind != kinds.first) + // { + // continue; + // } + } + + if (!target_entity) + { + target_entity = get_entity(entity_id_target, kinds.second); + } + else + { + // There are no possibility with the current kinds to arrive to this branch + assert(target_entity->kind == kinds.second); + // If in the future new kinds are added that could use this branch, use this code + // if (target_entity->kind != kinds.second) + // { + // continue; + // } + } + } + catch (const std::exception& e) + { + // It has not found the entity, check next possible kinds + continue; + } + + // In case both entities have been found, follow with them + break; + } + + // There is no way to set both to not null unless it is a pair with both types. + // Every time source entity is found in correct kind look for target, if found correct, if not target is null. + // Target does not look for an entity unless source has been found AND in the correct entity. + if (!source_entity || !target_entity) + { + throw BadParameter("Entity not found in required EntityKind for the given DataKind"); + } std::shared_lock lock(mutex_); std::vector samples; @@ -1467,8 +1559,6 @@ std::vector Database::select( { case DataKind::FASTDDS_LATENCY: { - assert(EntityKind::DATAWRITER == source_entity->kind); - assert(EntityKind::DATAREADER == target_entity->kind); auto writer = std::static_pointer_cast(source_entity); /* Look if the writer has information about the required reader */ auto reader = writer->data.history2history_latency.find(entity_id_target); @@ -1494,8 +1584,6 @@ std::vector Database::select( } case DataKind::NETWORK_LATENCY: { - assert(EntityKind::LOCATOR == source_entity->kind); - assert(EntityKind::LOCATOR == target_entity->kind); auto locator = std::static_pointer_cast(source_entity); /* Look if the locator has information about the required locator */ auto remote_locator = locator->data.network_latency_per_locator.find(entity_id_target); @@ -1518,8 +1606,6 @@ std::vector Database::select( } case DataKind::RTPS_PACKETS_SENT: { - assert(EntityKind::PARTICIPANT == source_entity->kind); - assert(EntityKind::LOCATOR == target_entity->kind); auto participant = std::static_pointer_cast(source_entity); /* Look if the participant has information about the required locator */ auto locator = participant->data.rtps_packets_sent.find(entity_id_target); @@ -1542,8 +1628,6 @@ std::vector Database::select( } case DataKind::RTPS_BYTES_SENT: { - assert(EntityKind::PARTICIPANT == source_entity->kind); - assert(EntityKind::LOCATOR == target_entity->kind); auto participant = std::static_pointer_cast(source_entity); /* Look if the participant has information about the required locator */ auto locator = participant->data.rtps_bytes_sent.find(entity_id_target); @@ -1566,8 +1650,6 @@ std::vector Database::select( } case DataKind::RTPS_PACKETS_LOST: { - assert(EntityKind::PARTICIPANT == source_entity->kind); - assert(EntityKind::LOCATOR == target_entity->kind); auto participant = std::static_pointer_cast(source_entity); /* Look if the participant has information about the required locator */ auto locator = participant->data.rtps_packets_lost.find(entity_id_target); @@ -1590,8 +1672,6 @@ std::vector Database::select( } case DataKind::RTPS_BYTES_LOST: { - assert(EntityKind::PARTICIPANT == source_entity->kind); - assert(EntityKind::LOCATOR == target_entity->kind); auto participant = std::static_pointer_cast(source_entity); /* Look if the participant has information about the required locator */ auto locator = participant->data.rtps_bytes_lost.find(entity_id_target); @@ -1614,9 +1694,6 @@ std::vector Database::select( } case DataKind::DISCOVERY_TIME: { - assert(EntityKind::PARTICIPANT == source_entity->kind); - assert(EntityKind::PARTICIPANT == target_entity->kind || EntityKind::DATAREADER == target_entity->kind || - EntityKind::DATAWRITER == target_entity->kind); auto participant = std::static_pointer_cast(source_entity); /* Look if the participant has information about the required dds entity */ auto dds_entity = participant->data.discovered_entity.find(entity_id_target); @@ -1657,7 +1734,28 @@ std::vector Database::select( throw BadParameter("Final timestamp must be strictly greater than the origin timestamp"); } - auto entity = get_entity(entity_id); + std::shared_ptr entity; + + for (auto kinds : StatisticsBackend::get_data_supported_entity_kinds(data_type)) + { + try + { + entity = get_entity(entity_id, kinds.first); + } + catch (const std::exception& e) + { + // It has not found the entity, check next possible kind + continue; + } + + // In case it has found the entity, follow with it + break; + } + + if (!entity) + { + throw BadParameter("Entity not found in required EntityKind for the given DataKind"); + } std::shared_lock lock(mutex_); std::vector samples; @@ -1665,7 +1763,6 @@ std::vector Database::select( { case DataKind::PUBLICATION_THROUGHPUT: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ // TODO(jlbueno) Knowing that the samples are ordered by timestamp it would be more efficient to @@ -1687,7 +1784,6 @@ std::vector Database::select( } case DataKind::SUBSCRIPTION_THROUGHPUT: { - assert(EntityKind::DATAREADER == entity->kind); auto reader = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : reader->data.subscription_throughput) @@ -1705,7 +1801,6 @@ std::vector Database::select( } case DataKind::RESENT_DATA: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : writer->data.resent_datas) @@ -1723,7 +1818,6 @@ std::vector Database::select( } case DataKind::HEARTBEAT_COUNT: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : writer->data.heartbeat_count) @@ -1741,7 +1835,6 @@ std::vector Database::select( } case DataKind::ACKNACK_COUNT: { - assert(EntityKind::DATAREADER == entity->kind); auto reader = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : reader->data.acknack_count) @@ -1759,7 +1852,6 @@ std::vector Database::select( } case DataKind::NACKFRAG_COUNT: { - assert(EntityKind::DATAREADER == entity->kind); auto reader = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : reader->data.nackfrag_count) @@ -1777,7 +1869,6 @@ std::vector Database::select( } case DataKind::GAP_COUNT: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : writer->data.gap_count) @@ -1795,7 +1886,6 @@ std::vector Database::select( } case DataKind::DATA_COUNT: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : writer->data.data_count) @@ -1813,7 +1903,6 @@ std::vector Database::select( } case DataKind::PDP_PACKETS: { - assert(EntityKind::PARTICIPANT == entity->kind); auto participant = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : participant->data.pdp_packets) @@ -1831,7 +1920,6 @@ std::vector Database::select( } case DataKind::EDP_PACKETS: { - assert(EntityKind::PARTICIPANT == entity->kind); auto participant = std::static_pointer_cast(entity); /* Look for the samples between the given timestamps */ for (auto& sample : participant->data.edp_packets) @@ -1849,7 +1937,6 @@ std::vector Database::select( } case DataKind::SAMPLE_DATAS: { - assert(EntityKind::DATAWRITER == entity->kind); auto writer = std::static_pointer_cast(entity); /* This case is different from the above. Check all map keys and add sample if it is between the given timestamps. The samples do not need to be ordered by source timestamp so they should be sorted */ @@ -1944,7 +2031,8 @@ EntityKind Database::get_entity_kind( const std::vector> Database::get_entities( EntityKind entity_kind, - const EntityId& entity_id) const + const EntityId& entity_id, + const EntityKind source_entity_kind /* = EntityKind::INVALID */) const { std::shared_ptr origin; @@ -1953,8 +2041,7 @@ const std::vector> Database::get_entities( { // This call will throw BadParameter if there is no such entity. // We let this exception through, as it meets expectations - origin = get_entity(entity_id); - assert(origin->kind != EntityKind::INVALID); + origin = get_entity(entity_id, source_entity_kind); } auto entities = get_entities(entity_kind, origin); @@ -1979,10 +2066,11 @@ const std::vector> Database::get_entities( std::vector Database::get_entity_ids( EntityKind entity_kind, - const EntityId& entity_id) const + const EntityId& entity_id, + const EntityKind source_entity_kind /* = EntityKind::INVALID */) const { std::vector entitiesIds; - for (const auto& entity : get_entities(entity_kind, entity_id)) + for (const auto& entity : get_entities(entity_kind, entity_id, source_entity_kind)) { entitiesIds.push_back(entity->id); } diff --git a/src/cpp/database/database.hpp b/src/cpp/database/database.hpp index 30ebcc85d..cd93820eb 100644 --- a/src/cpp/database/database.hpp +++ b/src/cpp/database/database.hpp @@ -215,11 +215,13 @@ class Database * Get an entity given its EntityId * * @param entity_id constant reference to the EntityId of the retrieved entity. + * @param entity_kind Kind of the entity to speed up the search. Default/Unknown INVALID. * @throws eprosima::statistics_backend::BadParameter if there is no entity with the given ID. * @return A constant shared pointer to the Entity. */ const std::shared_ptr get_entity( - const EntityId& entity_id) const; + const EntityId& entity_id, + const EntityKind entity_kind = EntityKind::INVALID) const; /** * Get all entities of a given EntityKind related to another entity. @@ -229,6 +231,7 @@ class Database * @param entity_id constant reference to the EntityId of the entity to which the returned * entities are related. * @param entity_kind The EntityKind of the fetched entities. + * @param source_entity_kind Kind of the source of the entity to speed up the search. Default/Unknown INVALID. * @throws eprosima::statistics_backend::BadParameter in the following case: * * if the \c entity_kind is \c INVALID. * * if the \c entity_id does not reference a entity contained in the database or is not EntityId::all(). @@ -237,7 +240,8 @@ class Database */ const std::vector> get_entities( EntityKind entity_kind, - const EntityId& entity_id) const; + const EntityId& entity_id, + const EntityKind source_entity_kind = EntityKind::INVALID) const; /** * Get all EntityIds of a given EntityKind related to another entity. @@ -247,6 +251,7 @@ class Database * @param entity_id constant reference to the EntityId of the entity to which the returned * entities are related. * @param entity_kind The EntityKind of the fetched entities. + * @param source_entity_kind Kind of the source of the entity to speed up the search. Default/Unknown INVALID. * @throws eprosima::statistics_backend::BadParameter in the following case: * * if the \c entity_kind is \c INVALID. * * if the \c entity_id does not reference a entity contained in the database or is not EntityId::all(). @@ -255,7 +260,8 @@ class Database */ std::vector get_entity_ids( EntityKind entity_type, - const EntityId& entity_id) const; + const EntityId& entity_id, + const EntityKind source_entity_kind = EntityKind::INVALID) const; /** * @brief Generate an EntityId that is unique for the database. diff --git a/src/cpp/database/database_queue.cpp b/src/cpp/database/database_queue.cpp index ec14b8755..aaa61eba1 100644 --- a/src/cpp/database/database_queue.cpp +++ b/src/cpp/database/database_queue.cpp @@ -699,7 +699,7 @@ void DatabaseDataQueue::process_sample() { // Host name reported by Fast DDS are considered unique std::shared_ptr const_host = std::dynamic_pointer_cast(database_->get_entity( - hosts.front().second)); + hosts.front().second, EntityKind::HOST)); host = std::const_pointer_cast(const_host); } @@ -709,7 +709,7 @@ void DatabaseDataQueue::process_sample() for (const auto& it : users) { std::shared_ptr const_user = - std::dynamic_pointer_cast(database_->get_entity(it.second)); + std::dynamic_pointer_cast(database_->get_entity(it.second, EntityKind::USER)); // The user name is unique within the host if (const_user->host == host) @@ -731,7 +731,9 @@ void DatabaseDataQueue::process_sample() for (const auto& it : processes) { std::shared_ptr const_process = - std::dynamic_pointer_cast(database_->get_entity(it.second)); + std::dynamic_pointer_cast(database_->get_entity( + it.second, + EntityKind::PROCESS)); // There is only one process with the same name for a given user if (const_process->user == user) diff --git a/src/cpp/subscriber/StatisticsParticipantListener.cpp b/src/cpp/subscriber/StatisticsParticipantListener.cpp index 0a69b63ab..576ed1bb8 100644 --- a/src/cpp/subscriber/StatisticsParticipantListener.cpp +++ b/src/cpp/subscriber/StatisticsParticipantListener.cpp @@ -66,7 +66,7 @@ void StatisticsParticipantListener::process_endpoint_discovery( // This may throw if the domain does not exist // The database MUST contain the domain, or something went wrong upstream std::shared_ptr domain = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(domain_id_))); + std::static_pointer_cast(database_->get_entity(domain_id_, EntityKind::DOMAIN))); // Get the participant from the database GUID_t endpoint_guid = info.info.guid(); @@ -86,7 +86,7 @@ void StatisticsParticipantListener::process_endpoint_discovery( std::shared_ptr participant = std::const_pointer_cast( std::static_pointer_cast(database_->get_entity( - participant_id.second))); + participant_id.second, EntityKind::PARTICIPANT))); assert(participant_id.first == domain_id_); @@ -100,7 +100,9 @@ void StatisticsParticipantListener::process_endpoint_discovery( if (topic_id.first == domain_id_) { topic = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(topic_id.second))); + std::static_pointer_cast(database_->get_entity( + topic_id.second, + EntityKind::TOPIC))); if (topic->data_type == info.info.typeName().to_string()) { @@ -134,7 +136,6 @@ void StatisticsParticipantListener::process_endpoint_discovery( auto endpoint = create_endpoint(endpoint_guid, info, participant, topic); /* Start processing the locator info */ - // Routine to process one locator from the locator list of the endpoint auto process_locators = [&](const Locator_t& dds_locator) { @@ -149,8 +150,9 @@ void StatisticsParticipantListener::process_endpoint_discovery( { // The locator exists. locator = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(locator_ids.front(). - second))); + std::static_pointer_cast(database_->get_entity( + locator_ids.front().second, + EntityKind::LOCATOR))); } else { @@ -319,7 +321,9 @@ void StatisticsParticipantListener::on_participant_discovery( database::EntityDiscoveryInfo entity_discovery_info; entity_discovery_info.domain_id = domain_id_; entity_discovery_info.entity = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(participant_id))); + std::static_pointer_cast(database_->get_entity( + participant_id, + EntityKind::PARTICIPANT))); switch (info.status) { @@ -352,7 +356,9 @@ void StatisticsParticipantListener::on_participant_discovery( // This may throw if the domain does not exist // The database MUST contain the domain, or something went wrong upstream std::shared_ptr domain = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(domain_id_))); + std::static_pointer_cast(database_->get_entity( + domain_id_, + EntityKind::DOMAIN))); std::string name = info.info.m_participantName.to_string(); @@ -418,7 +424,9 @@ void StatisticsParticipantListener::on_subscriber_discovery( database::EntityDiscoveryInfo entity_discovery_info; entity_discovery_info.domain_id = domain_id_; entity_discovery_info.entity = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(datareader_id))); + std::static_pointer_cast(database_->get_entity( + datareader_id, + EntityKind::DATAREADER))); switch (info.status) { @@ -488,7 +496,9 @@ void StatisticsParticipantListener::on_publisher_discovery( database::EntityDiscoveryInfo entity_discovery_info; entity_discovery_info.domain_id = domain_id_; entity_discovery_info.entity = std::const_pointer_cast( - std::static_pointer_cast(database_->get_entity(datawriter_id))); + std::static_pointer_cast(database_->get_entity( + datawriter_id, + EntityKind::DATAWRITER))); switch (info.status) { diff --git a/test/mock/database/database/database/database.hpp b/test/mock/database/database/database/database.hpp index 9536225c9..5bf3c86c9 100644 --- a/test/mock/database/database/database/database.hpp +++ b/test/mock/database/database/database/database.hpp @@ -83,14 +83,28 @@ class Database MOCK_CONST_METHOD1(get_entity, const std::shared_ptr( const EntityId& entity_id)); + MOCK_CONST_METHOD2(get_entity, const std::shared_ptr( + const EntityId& entity_id, + const EntityKind entity_kind)); + MOCK_CONST_METHOD2(get_entities, const std::vector>( EntityKind entity_kind, const EntityId& entity_id)); + MOCK_CONST_METHOD3(get_entities, const std::vector>( + EntityKind entity_kind, + const EntityId& entity_id, + const EntityKind source_entity_kind)); + MOCK_CONST_METHOD2(get_entity_ids, std::vector( EntityKind entity_kind, const EntityId& entity_id)); + MOCK_CONST_METHOD3(get_entity_ids, std::vector( + EntityKind entity_kind, + const EntityId& entity_id, + const EntityKind source_entity_kind)); + MOCK_CONST_METHOD2(get_entity_by_guid, std::pair( EntityKind entity_kind, const std::string& guid)); diff --git a/test/unittest/Database/CMakeLists.txt b/test/unittest/Database/CMakeLists.txt index fc1cc22ef..1deb9116c 100644 --- a/test/unittest/Database/CMakeLists.txt +++ b/test/unittest/Database/CMakeLists.txt @@ -300,7 +300,19 @@ set(DATABASE_TEST_LIST get_entity_datareader get_entity_datawriter get_entity_locator + get_entity_host_efficient_search + get_entity_process_efficient_search + get_entity_user_efficient_search + get_entity_domain_efficient_search + get_entity_topic_efficient_search + get_entity_participant_efficient_search + get_entity_datareader_efficient_search + get_entity_datawriter_efficient_search + get_entity_locator_efficient_search + get_entity_no_existing + get_entity_no_correct_kind + # get_entities_by_name get_entities_by_name_host get_entities_by_name_host_wrong_name @@ -473,7 +485,7 @@ endforeach() add_executable(database_load_tests DatabaseLoadTests.cpp ${LIBRARY_SOURCES}) if(MSVC) - target_compile_definitions(database_load_tests PRIVATE + target_compile_definitions(database_load_tests PRIVATE _CRT_DECLARE_NONSTDC_NAMES=0 FASTDDS_STATISTICS_BACKEND_SOURCE) endif(MSVC) @@ -525,7 +537,7 @@ endforeach() add_executable(database_load_insert_tests DatabaseLoadInsertTests.cpp ${LIBRARY_SOURCES}) if(MSVC) - target_compile_definitions(database_load_insert_tests PRIVATE + target_compile_definitions(database_load_insert_tests PRIVATE _CRT_DECLARE_NONSTDC_NAMES=0 FASTDDS_STATISTICS_BACKEND_SOURCE) endif(MSVC) @@ -565,7 +577,7 @@ endforeach() add_executable(database_status_tests DatabaseStatusTests.cpp ${LIBRARY_SOURCES}) if(MSVC) - target_compile_definitions(database_status_tests PRIVATE + target_compile_definitions(database_status_tests PRIVATE _CRT_DECLARE_NONSTDC_NAMES=0 FASTDDS_STATISTICS_BACKEND_SOURCE) endif(MSVC) @@ -615,7 +627,7 @@ endforeach() add_executable(database_erase_tests DatabaseEraseTests.cpp ${LIBRARY_SOURCES}) if(MSVC) - target_compile_definitions(database_erase_tests PRIVATE + target_compile_definitions(database_erase_tests PRIVATE _CRT_DECLARE_NONSTDC_NAMES=0 FASTDDS_STATISTICS_BACKEND_SOURCE) endif(MSVC) diff --git a/test/unittest/Database/DatabaseTests.cpp b/test/unittest/Database/DatabaseTests.cpp index a34d67199..b727ae9eb 100644 --- a/test/unittest/Database/DatabaseTests.cpp +++ b/test/unittest/Database/DatabaseTests.cpp @@ -2432,9 +2432,114 @@ TEST_F(database_tests, get_entity_locator) ASSERT_EQ(local_writer_locator.get(), writer_locator.get()); } +TEST_F(database_tests, get_entity_host_efficient_search) +{ + auto local_host = db.get_entity(host_id, EntityKind::HOST); + ASSERT_EQ(local_host.get(), host.get()); +} + +TEST_F(database_tests, get_entity_process_efficient_search) +{ + auto local_process = db.get_entity(process_id, EntityKind::PROCESS); + ASSERT_EQ(local_process.get(), process.get()); +} + +TEST_F(database_tests, get_entity_user_efficient_search) +{ + auto local_user = db.get_entity(user_id, EntityKind::USER); + ASSERT_EQ(local_user.get(), user.get()); +} + +TEST_F(database_tests, get_entity_domain_efficient_search) +{ + auto local_domain = db.get_entity(domain_id, EntityKind::DOMAIN); + ASSERT_EQ(local_domain.get(), domain.get()); +} + +TEST_F(database_tests, get_entity_topic_efficient_search) +{ + auto local_topic = db.get_entity(topic_id, EntityKind::TOPIC); + ASSERT_EQ(local_topic.get(), topic.get()); +} + +TEST_F(database_tests, get_entity_participant_efficient_search) +{ + auto local_participant = db.get_entity(participant_id, EntityKind::PARTICIPANT); + ASSERT_EQ(local_participant.get(), participant.get()); +} + +TEST_F(database_tests, get_entity_datareader_efficient_search) +{ + auto local_reader = db.get_entity(reader_id, EntityKind::DATAREADER); + ASSERT_EQ(local_reader.get(), reader.get()); +} + +TEST_F(database_tests, get_entity_datawriter_efficient_search) +{ + auto local_writer = db.get_entity(writer_id, EntityKind::DATAWRITER); + ASSERT_EQ(local_writer.get(), writer.get()); +} + +TEST_F(database_tests, get_entity_locator_efficient_search) +{ + auto local_reader_locator = db.get_entity(reader_locator->id, EntityKind::LOCATOR); + ASSERT_EQ(local_reader_locator.get(), reader_locator.get()); + auto local_writer_locator = db.get_entity(writer_locator->id, EntityKind::LOCATOR); + ASSERT_EQ(local_writer_locator.get(), writer_locator.get()); +} + TEST_F(database_tests, get_entity_no_existing) { ASSERT_THROW(db.get_entity(EntityId()), BadParameter); + // With specific kind + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::HOST), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::USER), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::PROCESS), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::DOMAIN), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::TOPIC), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::PARTICIPANT), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::DATAREADER), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::DATAWRITER), BadParameter); + ASSERT_THROW(db.get_entity(EntityId(), EntityKind::LOCATOR), BadParameter); +} + +TEST_F(database_tests, get_entity_no_correct_kind) +{ + std::map correct_kinds = { + {host_id, EntityKind::HOST}, + {process_id, EntityKind::PROCESS}, + {user_id, EntityKind::USER}, + {domain_id, EntityKind::DOMAIN}, + {topic_id, EntityKind::TOPIC}, + {participant_id, EntityKind::PARTICIPANT}, + {reader_id, EntityKind::DATAREADER}, + {writer_id, EntityKind::DATAWRITER}, + {reader_locator->id, EntityKind::LOCATOR}, + {writer_locator->id, EntityKind::LOCATOR} + }; + + std::vector all_kinds = { + EntityKind::HOST, + EntityKind::PROCESS, + EntityKind::USER, + EntityKind::DOMAIN, + EntityKind::TOPIC, + EntityKind::PARTICIPANT, + EntityKind::DATAREADER, + EntityKind::DATAWRITER, + EntityKind::LOCATOR + }; + + for (auto correct_kind : correct_kinds) + { + for (auto kind : all_kinds) + { + if (kind != correct_kind.second) + { + ASSERT_THROW(db.get_entity(correct_kind.first, kind), BadParameter); + } + } + } } TEST_F(database_tests, get_entities_by_name_host) @@ -2714,235 +2819,237 @@ TEST_F(database_tests, select_double_entity_invalid_needs_one_entity) TEST_F(database_tests, select_invalid_entities) { -#ifndef NDEBUG - // Test assertions + // Test Bad Parameter errors Timestamp t_from = std::chrono::system_clock::now(); Timestamp t_to = t_from + std::chrono::seconds(1); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, host_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, user_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, process_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, domain_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, topic_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, participant_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, reader_id, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, reader_locator->id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::FASTDDS_LATENCY, writer_id, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, host_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, user_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, process_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, domain_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, topic_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, participant_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, writer_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_id, reader_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PUBLICATION_THROUGHPUT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, host_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, user_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, process_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, domain_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, topic_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, writer_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, reader_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, writer_locator->id, reader_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, host_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, user_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, process_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, domain_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, topic_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, writer_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, reader_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, writer_locator->id, reader_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_SENT, participant_id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, host_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, user_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, process_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, domain_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, topic_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, writer_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, reader_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, writer_locator->id, reader_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, host_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, user_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, process_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, domain_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, topic_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, writer_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, reader_id, reader_locator->id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, writer_locator->id, reader_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RTPS_BYTES_LOST, participant_id, reader_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::RESENT_DATA, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::HEARTBEAT_COUNT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::ACKNACK_COUNT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::NACKFRAG_COUNT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::GAP_COUNT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DATA_COUNT, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::PDP_PACKETS, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, writer_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::EDP_PACKETS, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, host_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, user_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, process_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, domain_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, topic_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, writer_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, reader_id, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, writer_locator->id, participant_id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::DISCOVERY_TIME, participant_id, writer_locator->id, t_from, t_to), ""); - - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, host_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, user_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, process_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, domain_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, topic_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, participant_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, reader_id, t_from, t_to), ""); - ASSERT_DEATH(db.select(DataKind::SAMPLE_DATAS, writer_locator->id, t_from, t_to), ""); -#endif // ifndef NDEBUG + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, host_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, user_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, process_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, domain_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, topic_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, participant_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, reader_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, reader_locator->id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, host_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, user_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, process_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, domain_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, topic_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, participant_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, writer_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_id, reader_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, host_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, user_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, process_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, domain_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, topic_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, writer_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, reader_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, writer_locator->id, reader_locator->id, t_from, + t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, participant_id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, host_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, user_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, process_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, domain_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, topic_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, writer_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, reader_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, writer_locator->id, reader_locator->id, t_from, + t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, participant_id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, host_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, user_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, process_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, domain_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, topic_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, writer_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, reader_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, writer_locator->id, reader_locator->id, t_from, + t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, participant_id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, host_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, user_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, process_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, domain_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, topic_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, writer_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, reader_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, writer_locator->id, reader_locator->id, t_from, + t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, participant_id, reader_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::RESENT_DATA, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RESENT_DATA, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::HEARTBEAT_COUNT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::ACKNACK_COUNT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NACKFRAG_COUNT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::GAP_COUNT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::GAP_COUNT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::DATA_COUNT, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DATA_COUNT, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::PDP_PACKETS, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, writer_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::EDP_PACKETS, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, host_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, user_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, process_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, domain_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, topic_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, writer_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, reader_id, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, writer_locator->id, participant_id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, writer_locator->id, t_from, t_to), BadParameter); + + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, host_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, user_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, process_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, domain_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, topic_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, participant_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::SAMPLE_DATAS, writer_locator->id, t_from, t_to), BadParameter); } TEST_F(database_tests, select_invalid_entity_id) @@ -2952,19 +3059,31 @@ TEST_F(database_tests, select_invalid_entity_id) EntityId invalid_id; EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, invalid_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::FASTDDS_LATENCY, writer_id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, invalid_id, writer_locator->id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, invalid_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, writer_locator->id, invalid_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::NETWORK_LATENCY, reader_locator->id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, invalid_id, writer_locator->id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, invalid_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, writer_locator->id, invalid_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_SENT, reader_locator->id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, invalid_id, writer_locator->id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, invalid_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, writer_locator->id, invalid_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_SENT, reader_locator->id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, invalid_id, writer_locator->id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, invalid_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, writer_locator->id, invalid_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_PACKETS_LOST, reader_locator->id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, invalid_id, writer_locator->id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, invalid_id, reader_locator->id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, writer_locator->id, invalid_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::RTPS_BYTES_LOST, reader_locator->id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, invalid_id, participant_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, invalid_id, writer_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, invalid_id, reader_id, t_from, t_to), BadParameter); + EXPECT_THROW(db.select(DataKind::DISCOVERY_TIME, participant_id, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::PUBLICATION_THROUGHPUT, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::SUBSCRIPTION_THROUGHPUT, invalid_id, t_from, t_to), BadParameter); EXPECT_THROW(db.select(DataKind::RESENT_DATA, invalid_id, t_from, t_to), BadParameter); diff --git a/test/unittest/DatabaseQueue/DatabaseQueueTests.cpp b/test/unittest/DatabaseQueue/DatabaseQueueTests.cpp index 799908227..ac63657e1 100644 --- a/test/unittest/DatabaseQueue/DatabaseQueueTests.cpp +++ b/test/unittest/DatabaseQueue/DatabaseQueueTests.cpp @@ -3441,7 +3441,7 @@ TEST_F(database_queue_tests, push_physical_data_process_exists) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(1) .WillOnce(Return(host)); // Precondition: The user exists and has ID 3 @@ -3450,7 +3450,7 @@ TEST_F(database_queue_tests, push_physical_data_process_exists) auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::USER)).Times(1) .WillOnce(Return(user)); // Precondition: The process exists and has ID 4 @@ -3459,7 +3459,7 @@ TEST_F(database_queue_tests, push_physical_data_process_exists) auto process = std::make_shared(processname, pid, user); process->id = EntityId(4); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::PROCESS)).Times(1) .WillOnce(Return(process)); // Expectation: The link method is called with appropriate arguments @@ -3519,7 +3519,7 @@ TEST_F(database_queue_tests, push_physical_data_no_participant_exists) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(AnyNumber()) .WillOnce(Return(host)); // Precondition: The user exists and has ID 3 @@ -3528,7 +3528,7 @@ TEST_F(database_queue_tests, push_physical_data_no_participant_exists) auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::USER)).Times(AnyNumber()) .WillOnce(Return(user)); // Precondition: The process exists and has ID 4 @@ -3537,7 +3537,7 @@ TEST_F(database_queue_tests, push_physical_data_no_participant_exists) auto process = std::make_shared(processname, pid, user); process->id = EntityId(4); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::PROCESS)).Times(AnyNumber()) .WillOnce(Return(process)); // Expectation: The user is not notified @@ -3597,7 +3597,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_exists) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(1) .WillOnce(Return(host)); // Precondition: The user exists and has ID 3 @@ -3606,7 +3606,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_exists) auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::USER)).Times(1) .WillOnce(Return(user)); // Precondition: The process does not exist @@ -3689,7 +3689,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_exists_process_insert auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(1) .WillOnce(Return(host)); // Precondition: The user exists and has ID 3 @@ -3699,7 +3699,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_exists_process_insert auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::USER)).Times(1) .WillOnce(Return(user)); // Precondition: The process does not exist @@ -3783,7 +3783,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_no_user_exists) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(1) .WillOnce(Return(host)); // Precondition: The user does not exist @@ -3888,7 +3888,7 @@ TEST_F(database_queue_tests, push_physical_data_no_process_no_user_exists_user_i auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(1) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(1) .WillOnce(Return(host)); // Precondition: The user does not exist @@ -4170,7 +4170,7 @@ TEST_F(database_queue_tests, push_physical_data_wrong_processname_format) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::HOST)).Times(AnyNumber()) .WillOnce(Return(host)); // Precondition: The user exists and has ID 3 @@ -4179,7 +4179,7 @@ TEST_F(database_queue_tests, push_physical_data_wrong_processname_format) auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::USER)).Times(AnyNumber()) .WillOnce(Return(user)); // Precondition: The process does not exist diff --git a/test/unittest/StatisticsParticipantListener/StatisticsParticipantListenerTests.cpp b/test/unittest/StatisticsParticipantListener/StatisticsParticipantListenerTests.cpp index fea037cfd..67ca4499c 100644 --- a/test/unittest/StatisticsParticipantListener/StatisticsParticipantListenerTests.cpp +++ b/test/unittest/StatisticsParticipantListener/StatisticsParticipantListenerTests.cpp @@ -171,7 +171,8 @@ class statistics_participant_listener_tests : public ::testing::Test AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()).WillRepeatedly(Return(domain_)); + EXPECT_CALL(database, + get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()).WillRepeatedly(Return(domain_)); // Precondition: The Participant does not exist EXPECT_CALL(database, @@ -205,7 +206,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant does not exist @@ -254,7 +255,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_undiscovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant does not exist @@ -361,7 +362,9 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()).WillRepeatedly(Return( std::vector>(1, std::make_pair( EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()).WillRepeatedly(Return(existing_unicast_locator)); + EXPECT_CALL(database, + get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()).WillRepeatedly(Return( + existing_unicast_locator)); // Precondition: The discovered reader contains the locator data.default_locators.add_unicast_locator(dds_existing_unicast_locator); @@ -380,7 +383,8 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()).WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); EXPECT_CALL(database, - get_entity(EntityId(4))).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); + get_entity(EntityId(4), + EntityKind::LOCATOR)).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); // Precondition: The discovered reader contains the locator data.metatraffic_locators.add_unicast_locator(dds_existing_metatraffic_unicast_locator); @@ -398,7 +402,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(5))))); - EXPECT_CALL(database, get_entity(EntityId(5))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(5), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -418,7 +422,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(6))))); - EXPECT_CALL(database, get_entity(EntityId(6))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(6), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_metatraffic_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -486,7 +490,8 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()).WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); EXPECT_CALL(database, - get_entity(EntityId(4))).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); + get_entity(EntityId(4), + EntityKind::LOCATOR)).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); // Precondition: The discovered reader contains the locator data.metatraffic_locators.add_unicast_locator(dds_existing_metatraffic_unicast_locator); @@ -504,7 +509,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(5))))); - EXPECT_CALL(database, get_entity(EntityId(5))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(5), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -524,7 +529,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(6))))); - EXPECT_CALL(database, get_entity(EntityId(6))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(6), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_metatraffic_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -592,7 +597,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(5))))); - EXPECT_CALL(database, get_entity(EntityId(5))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(5), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -612,7 +617,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(6))))); - EXPECT_CALL(database, get_entity(EntityId(6))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(6), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_metatraffic_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -680,14 +685,14 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(6))))); - EXPECT_CALL(database, get_entity(EntityId(6))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(6), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_metatraffic_multicast_locator)); // Precondition: The discovered reader contains the locator data.metatraffic_locators.add_multicast_locator(dds_existing_metatraffic_multicast_locator); // Precondition: There are 1 locator - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>({existing_metatraffic_multicast_locator}))); // Expectation: The Participant is added to the database. We do not care about the given ID @@ -743,7 +748,9 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()).WillRepeatedly(Return( std::vector>(1, std::make_pair( EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()).WillRepeatedly(Return(existing_unicast_locator)); + EXPECT_CALL(database, + get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()).WillRepeatedly(Return( + existing_unicast_locator)); // Precondition: The discovered reader contains the locator data.default_locators.add_unicast_locator(dds_existing_unicast_locator); @@ -760,7 +767,8 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()).WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); EXPECT_CALL(database, - get_entity(EntityId(4))).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); + get_entity(EntityId(4), + EntityKind::LOCATOR)).Times(AnyNumber()).WillRepeatedly(Return(existing_metatraffic_unicast_locator)); // Precondition: The discovered reader contains the locator data.metatraffic_locators.add_unicast_locator(dds_existing_metatraffic_unicast_locator); @@ -776,7 +784,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(5))))); - EXPECT_CALL(database, get_entity(EntityId(5))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(5), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -794,7 +802,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_empty_n AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(6))))); - EXPECT_CALL(database, get_entity(EntityId(6))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(6), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_metatraffic_multicast_locator)); // Precondition: The discovered reader contains the locator @@ -842,7 +850,7 @@ TEST_F(statistics_participant_listener_tests, new_participant_no_domain) get_entities_by_name(EntityKind::DOMAIN, std::to_string(statistics_participant.domain_id_))).Times( AnyNumber()) .WillRepeatedly(Return(std::vector>())); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Throw(eprosima::statistics_backend::BadParameter("Error"))); // Precondition: The Participant does not exist @@ -876,14 +884,14 @@ TEST_F(statistics_participant_listener_tests, new_participant_discovered_partici AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 participant_->id = EntityId(1); EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Start building the discovered reader info @@ -916,14 +924,14 @@ TEST_F(statistics_participant_listener_tests, new_participant_undiscovered_parti AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 participant_->id = EntityId(1); EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Start building the discovered reader info @@ -963,29 +971,29 @@ TEST_F(statistics_participant_listener_tests, new_reader_discovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -999,9 +1007,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_discovered) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1066,29 +1074,29 @@ TEST_F(statistics_participant_listener_tests, new_reader_undiscovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -1102,9 +1110,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_undiscovered) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1148,22 +1156,22 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_topic) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic does not exist @@ -1181,9 +1189,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_topic) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1267,22 +1275,22 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_topics) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: Another domain with ID 100 exists @@ -1292,24 +1300,24 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_topics) get_entities_by_name(EntityKind::DOMAIN, another_domain_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(100), EntityId(100))))); - EXPECT_CALL(database, get_entity(EntityId(100))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(100), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(another_domain)); // Precondition: Another topic with the same name and type exists in domain 100 // and has ID 101 std::shared_ptr topic_another_domain = std::make_shared(topic_name_, type_name_, another_domain); - EXPECT_CALL(database, get_entity(EntityId(101))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(101), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_another_domain)); // Precondition: Another topic with the same name but different type exists in the initial domain 0 // and has ID 102 std::string another_type_name = "another_type"; std::shared_ptr topic_another_type = std::make_shared(topic_name_, another_type_name, domain_); - EXPECT_CALL(database, get_entity(EntityId(102))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(102), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_another_type)); // Precondition: The Topic exists and has ID 2 - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) @@ -1329,9 +1337,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_topics) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1399,29 +1407,29 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: One unicast Locator exists and has ID 3 @@ -1435,7 +1443,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); existing_locators.push_back(existing_unicast_locator); @@ -1450,7 +1458,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); existing_locators.push_back(existing_multicast_locator); @@ -1475,7 +1483,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators) .WillRepeatedly(Return(std::vector>())); // Precondition: Looking for the entities from the locator returns existing locators - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(existing_locators)); // Precondition: The database returns EntityIDs that are not used before @@ -1568,23 +1576,23 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators_no_hos AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 // Precondition: The Participant is NOT linked to any host EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>())); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: One unicast Locator exists and has ID 3 @@ -1598,7 +1606,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators_no_hos EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); existing_locators.push_back(existing_unicast_locator); @@ -1613,7 +1621,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators_no_hos EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); existing_locators.push_back(existing_multicast_locator); @@ -1638,7 +1646,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_several_locators_no_hos .WillRepeatedly(Return(std::vector>())); // Precondition: Looking for the entities from the locator returns existing locators - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(existing_locators)); // Precondition: The database returns EntityIDs that are not used before @@ -1728,7 +1736,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_participant) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant does not exist @@ -1739,7 +1747,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_participant) EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -1753,9 +1761,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_participant) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1792,7 +1800,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_domain) get_entities_by_name(EntityKind::DOMAIN, std::to_string(statistics_participant.domain_id_))).Times( AnyNumber()) .WillRepeatedly(Return(std::vector>())); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Throw(eprosima::statistics_backend::BadParameter("Error"))); // Precondition: The Participant does not exist @@ -1814,9 +1822,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_no_domain) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1855,29 +1863,29 @@ TEST_F(statistics_participant_listener_tests, new_reader_discovered_reader_alrea AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -1891,9 +1899,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_discovered_reader_alrea EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -1919,7 +1927,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_discovered_reader_alrea reader->id = 10; EXPECT_CALL(database, get_entity_by_guid(EntityKind::DATAREADER, reader_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(10)))); - EXPECT_CALL(database, get_entity(EntityId(10))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(10), EntityKind::DATAREADER)).Times(AnyNumber()) .WillRepeatedly(Return(reader)); // Expectation: The DataReader is not inserted in the database. @@ -1941,29 +1949,29 @@ TEST_F(statistics_participant_listener_tests, new_reader_undiscovered_reader_alr AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -1977,9 +1985,9 @@ TEST_F(statistics_participant_listener_tests, new_reader_undiscovered_reader_alr EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered reader info @@ -2005,7 +2013,7 @@ TEST_F(statistics_participant_listener_tests, new_reader_undiscovered_reader_alr reader->id = 10; EXPECT_CALL(database, get_entity_by_guid(EntityKind::DATAREADER, reader_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(10)))); - EXPECT_CALL(database, get_entity(EntityId(10))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(10), EntityKind::DATAREADER)).Times(AnyNumber()) .WillRepeatedly(Return(reader)); // Expectation: The DataReader is not inserted in the database. @@ -2029,29 +2037,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_discovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -2065,9 +2073,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_discovered) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2132,29 +2140,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_undiscovered) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -2168,9 +2176,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_undiscovered) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2214,22 +2222,22 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_topic) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic does not exist @@ -2247,9 +2255,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_topic) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2337,29 +2345,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: One unicast Locator exists and has ID 3 @@ -2373,7 +2381,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); existing_locators.push_back(existing_unicast_locator); @@ -2388,7 +2396,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); existing_locators.push_back(existing_multicast_locator); @@ -2413,7 +2421,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators .WillRepeatedly(Return(std::vector>())); // Precondition: Looking for the entities from the locator returns existing locators - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(existing_locators)); // Precondition: The database returns EntityIDs that are not used before @@ -2506,23 +2514,23 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators_no_hos AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 // Precondition: The Participant is NOT linked to any host EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>())); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: One unicast Locator exists and has ID 3 @@ -2536,7 +2544,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators_no_hos EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); existing_locators.push_back(existing_unicast_locator); @@ -2551,7 +2559,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators_no_hos EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_multicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(4))))); - EXPECT_CALL(database, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(4), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_multicast_locator)); existing_locators.push_back(existing_multicast_locator); @@ -2576,7 +2584,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_several_locators_no_hos .WillRepeatedly(Return(std::vector>())); // Precondition: Looking for the entities from the locator returns existing locators - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(existing_locators)); // Precondition: The database returns EntityIDs that are not used before @@ -2666,7 +2674,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_participant) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant does not exist @@ -2677,7 +2685,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_participant) EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -2691,9 +2699,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_participant) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2731,7 +2739,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_domain) get_entities_by_name(EntityKind::DOMAIN, std::to_string(statistics_participant.domain_id_))).Times( AnyNumber()) .WillRepeatedly(Return(std::vector>())); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Throw(eprosima::statistics_backend::BadParameter("Error"))); // Precondition: The Participant does not exist @@ -2753,9 +2761,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_no_domain) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2794,29 +2802,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_discovered_writer_alrea AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -2830,9 +2838,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_discovered_writer_alrea EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2858,7 +2866,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_discovered_writer_alrea writer->id = EntityId(10); EXPECT_CALL(database, get_entity_by_guid(EntityKind::DATAWRITER, writer_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(10)))); - EXPECT_CALL(database, get_entity(EntityId(10))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(10), EntityKind::DATAWRITER)).Times(AnyNumber()) .WillRepeatedly(Return(writer)); // Expectation: The DataWriter is not inserted in the database. @@ -2880,29 +2888,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_undiscovered_writer_alr AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -2916,9 +2924,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_undiscovered_writer_alr EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info @@ -2944,7 +2952,7 @@ TEST_F(statistics_participant_listener_tests, new_writer_undiscovered_writer_alr writer->id = EntityId(10); EXPECT_CALL(database, get_entity_by_guid(EntityKind::DATAWRITER, writer_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(10)))); - EXPECT_CALL(database, get_entity(EntityId(10))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(10), EntityKind::DATAWRITER)).Times(AnyNumber()) .WillRepeatedly(Return(writer)); // Expectation: The DataWriter is not inserted in the database. @@ -2967,29 +2975,29 @@ TEST_F(statistics_participant_listener_tests, new_writer_statistics_writer) AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(0))))); - EXPECT_CALL(database, get_entity(EntityId(0))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(0), EntityKind::DOMAIN)).Times(AnyNumber()) .WillRepeatedly(Return(domain_)); // Precondition: The Participant exists and has ID 1 EXPECT_CALL(database, get_entity_by_guid(EntityKind::PARTICIPANT, participant_guid_str_)).Times(AnyNumber()) .WillRepeatedly(Return(std::make_pair(EntityId(0), EntityId(1)))); - EXPECT_CALL(database, get_entity(EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(participant_)); // Precondition: The Participant is linked to a host with ID 50 std::string host_name = "hostname"; std::shared_ptr host = std::make_shared(host_name); - EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::HOST, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, host))); - EXPECT_CALL(database, get_entity(EntityId(50))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(50), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The Topic exists and has ID 2 EXPECT_CALL(database, get_entities_by_name(EntityKind::TOPIC, topic_name_)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(0), EntityId(2))))); - EXPECT_CALL(database, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(2), EntityKind::TOPIC)).Times(AnyNumber()) .WillRepeatedly(Return(topic_)); // Precondition: The Locator exists and has ID 3 @@ -3003,9 +3011,9 @@ TEST_F(statistics_participant_listener_tests, new_writer_statistics_writer) EXPECT_CALL(database, get_entities_by_name(EntityKind::LOCATOR, existing_unicast_locator_name)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, std::make_pair(EntityId(), EntityId(3))))); - EXPECT_CALL(database, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database, get_entity(EntityId(3), EntityKind::LOCATOR)).Times(AnyNumber()) .WillRepeatedly(Return(existing_unicast_locator)); - EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1))).Times(AnyNumber()) + EXPECT_CALL(database, get_entities(EntityKind::LOCATOR, EntityId(1), EntityKind::PARTICIPANT)).Times(AnyNumber()) .WillRepeatedly(Return(std::vector>(1, existing_unicast_locator))); // Start building the discovered writer info diff --git a/test/unittest/StatisticsReaderListener/StatisticsReaderListenerTests.cpp b/test/unittest/StatisticsReaderListener/StatisticsReaderListenerTests.cpp index c47ce3a4e..d73c92906 100644 --- a/test/unittest/StatisticsReaderListener/StatisticsReaderListenerTests.cpp +++ b/test/unittest/StatisticsReaderListener/StatisticsReaderListenerTests.cpp @@ -1345,7 +1345,7 @@ TEST_F(statistics_reader_listener_tests, new_physical_data_received) auto host = std::make_shared(hostname); host->id = EntityId(2); - EXPECT_CALL(database_, get_entity(EntityId(2))).Times(AnyNumber()) + EXPECT_CALL(database_, get_entity(EntityId(2), EntityKind::HOST)).Times(AnyNumber()) .WillRepeatedly(Return(host)); // Precondition: The user exists and has ID 3 @@ -1355,7 +1355,7 @@ TEST_F(statistics_reader_listener_tests, new_physical_data_received) auto user = std::make_shared(username, host); user->id = EntityId(3); - EXPECT_CALL(database_, get_entity(EntityId(3))).Times(AnyNumber()) + EXPECT_CALL(database_, get_entity(EntityId(3), EntityKind::USER)).Times(AnyNumber()) .WillRepeatedly(Return(user)); // Precondition: The process exists and has ID 4 @@ -1365,7 +1365,7 @@ TEST_F(statistics_reader_listener_tests, new_physical_data_received) auto process = std::make_shared(processname, pid, user); process->id = EntityId(4); - EXPECT_CALL(database_, get_entity(EntityId(4))).Times(AnyNumber()) + EXPECT_CALL(database_, get_entity(EntityId(4), EntityKind::PROCESS)).Times(AnyNumber()) .WillRepeatedly(Return(process)); // Expectation: The link method is called with appropriate arguments