diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index 20febf03c9c8141c1188b50b8e38841ff04d51bb..254c39555e012f6b3823492c66cda30743e7c6d4 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -326,6 +326,9 @@ public: [[nodiscard]] auto GetWarnings() const -> const Messages & { return warnings; } + [[nodiscard]] inline auto HasWarnings() const -> bool { + return this->warnings.wrapped->size() > 0; + } [[nodiscard]] auto GetInfos() const -> const Messages & { return infos; } inline auto ToString() const -> const std::string { diff --git a/test/test_entity.cpp b/test/test_entity.cpp index 1f3adf99b0702f7a369e20b42d2f8a3af3ea94dd..4a505b3488f5ec644c615a104d480f0b69c572c0 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -85,6 +85,7 @@ TEST(test_entity, test_from_id_response) { // NOLINT std::cout << entity.ToString() << std::endl; EXPECT_EQ(entity.GetId(), "entity_id"); + EXPECT_TRUE(entity.HasErrors()); EXPECT_EQ(entity.GetErrors().Size(), 1); EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "error_desc"); EXPECT_EQ(entity.GetErrors().At(0).GetCode(), @@ -103,6 +104,7 @@ TEST(test_entity, test_from_id_response) { // NOLINT EXPECT_EQ(other_ent.GetId(), "other_entity_id"); EXPECT_EQ(other_ent.GetWarnings().Size(), 1); + EXPECT_TRUE(other_ent.HasWarnings()); EXPECT_EQ(other_ent.GetWarnings().At(0).GetDescription(), "warning_desc"); EXPECT_EQ(other_ent.GetWarnings().At(0).GetCode(), MessageCode::ENTITY_HAS_NO_PROPERTIES);