@@ -2432,9 +2432,114 @@ TEST_F(database_tests, get_entity_locator)
2432
2432
ASSERT_EQ (local_writer_locator.get (), writer_locator.get ());
2433
2433
}
2434
2434
2435
+ TEST_F (database_tests, get_entity_host_efficient_search)
2436
+ {
2437
+ auto local_host = db.get_entity (host_id, EntityKind::HOST);
2438
+ ASSERT_EQ (local_host.get (), host.get ());
2439
+ }
2440
+
2441
+ TEST_F (database_tests, get_entity_process_efficient_search)
2442
+ {
2443
+ auto local_process = db.get_entity (process_id, EntityKind::PROCESS);
2444
+ ASSERT_EQ (local_process.get (), process.get ());
2445
+ }
2446
+
2447
+ TEST_F (database_tests, get_entity_user_efficient_search)
2448
+ {
2449
+ auto local_user = db.get_entity (user_id, EntityKind::USER);
2450
+ ASSERT_EQ (local_user.get (), user.get ());
2451
+ }
2452
+
2453
+ TEST_F (database_tests, get_entity_domain_efficient_search)
2454
+ {
2455
+ auto local_domain = db.get_entity (domain_id, EntityKind::DOMAIN);
2456
+ ASSERT_EQ (local_domain.get (), domain.get ());
2457
+ }
2458
+
2459
+ TEST_F (database_tests, get_entity_topic_efficient_search)
2460
+ {
2461
+ auto local_topic = db.get_entity (topic_id, EntityKind::TOPIC);
2462
+ ASSERT_EQ (local_topic.get (), topic.get ());
2463
+ }
2464
+
2465
+ TEST_F (database_tests, get_entity_participant_efficient_search)
2466
+ {
2467
+ auto local_participant = db.get_entity (participant_id, EntityKind::PARTICIPANT);
2468
+ ASSERT_EQ (local_participant.get (), participant.get ());
2469
+ }
2470
+
2471
+ TEST_F (database_tests, get_entity_datareader_efficient_search)
2472
+ {
2473
+ auto local_reader = db.get_entity (reader_id, EntityKind::DATAREADER);
2474
+ ASSERT_EQ (local_reader.get (), reader.get ());
2475
+ }
2476
+
2477
+ TEST_F (database_tests, get_entity_datawriter_efficient_search)
2478
+ {
2479
+ auto local_writer = db.get_entity (writer_id, EntityKind::DATAWRITER);
2480
+ ASSERT_EQ (local_writer.get (), writer.get ());
2481
+ }
2482
+
2483
+ TEST_F (database_tests, get_entity_locator_efficient_search)
2484
+ {
2485
+ auto local_reader_locator = db.get_entity (reader_locator->id , EntityKind::LOCATOR);
2486
+ ASSERT_EQ (local_reader_locator.get (), reader_locator.get ());
2487
+ auto local_writer_locator = db.get_entity (writer_locator->id , EntityKind::LOCATOR);
2488
+ ASSERT_EQ (local_writer_locator.get (), writer_locator.get ());
2489
+ }
2490
+
2435
2491
TEST_F (database_tests, get_entity_no_existing)
2436
2492
{
2437
2493
ASSERT_THROW (db.get_entity (EntityId ()), BadParameter);
2494
+ // With specific kind
2495
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::HOST), BadParameter);
2496
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::USER), BadParameter);
2497
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::PROCESS), BadParameter);
2498
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::DOMAIN), BadParameter);
2499
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::TOPIC), BadParameter);
2500
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::PARTICIPANT), BadParameter);
2501
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::DATAREADER), BadParameter);
2502
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::DATAWRITER), BadParameter);
2503
+ ASSERT_THROW (db.get_entity (EntityId (), EntityKind::LOCATOR), BadParameter);
2504
+ }
2505
+
2506
+ TEST_F (database_tests, get_entity_no_correct_kind)
2507
+ {
2508
+ std::map<EntityId, EntityKind> correct_kinds = {
2509
+ {host_id, EntityKind::HOST},
2510
+ {process_id, EntityKind::PROCESS},
2511
+ {user_id, EntityKind::USER},
2512
+ {domain_id, EntityKind::DOMAIN},
2513
+ {topic_id, EntityKind::TOPIC},
2514
+ {participant_id, EntityKind::PARTICIPANT},
2515
+ {reader_id, EntityKind::DATAREADER},
2516
+ {writer_id, EntityKind::DATAWRITER},
2517
+ {reader_locator->id , EntityKind::LOCATOR},
2518
+ {writer_locator->id , EntityKind::LOCATOR}
2519
+ };
2520
+
2521
+ std::vector<EntityKind> all_kinds = {
2522
+ EntityKind::HOST,
2523
+ EntityKind::PROCESS,
2524
+ EntityKind::USER,
2525
+ EntityKind::DOMAIN,
2526
+ EntityKind::TOPIC,
2527
+ EntityKind::PARTICIPANT,
2528
+ EntityKind::DATAREADER,
2529
+ EntityKind::DATAWRITER,
2530
+ EntityKind::LOCATOR
2531
+ };
2532
+
2533
+ for (auto correct_kind : correct_kinds)
2534
+ {
2535
+ for (auto kind : all_kinds)
2536
+ {
2537
+ if (kind != correct_kind.second )
2538
+ {
2539
+ ASSERT_THROW (db.get_entity (correct_kind.first , kind), BadParameter);
2540
+ }
2541
+ }
2542
+ }
2438
2543
}
2439
2544
2440
2545
TEST_F (database_tests, get_entities_by_name_host)
0 commit comments