diff --git a/test/test_entity.cpp b/test/test_entity.cpp index 66423eb49300422439a75ec20f35e63d703053c1..60177fb74b26f58a7bb2adac3a13ebd4ab6bec07 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -98,6 +98,31 @@ TEST(test_entity, test_insert_with_role) { // NOLINT EXPECT_EQ(entity.GetValue(), "5.5"); } +TEST(test_entity, test_insert_with_parent) { + auto transaction = caosdb::transaction::Transaction( + std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr)); + + auto entity = Entity(); + entity.SetId("entity_id"); + + auto parent = Parent(); + parent.SetId("parent_id"); + parent.SetName("parent_name"); + EXPECT_EQ(parent.GetId(), "parent_id"); + EXPECT_EQ(parent.GetName(), "parent_name"); + + entity.AppendParent(parent); + + transaction.InsertEntity(&entity); + + std::cout << entity.ToString() << std::endl; + EXPECT_EQ(entity.GetId(), "entity_id"); + EXPECT_EQ(entity.GetParents().Size(), 1); + auto inserted_parent = entity.GetParents().At(0); + EXPECT_EQ(inserted_parent.GetId(), parent.GetId()); + EXPECT_EQ(inserted_parent.GetName(), parent.GetName()); +} + // TODO(tf) cognitive complexity > 25 (threshold) TEST(test_entity, test_from_id_response) { // NOLINT IdResponse idResponse;