From 58940216b1c2f0811cae1b417a1db2a1f548216c Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Mon, 2 Aug 2021 15:11:00 +0200
Subject: [PATCH] ENH: Add HasWarnings

---
 include/caosdb/entity.h | 3 +++
 test/test_entity.cpp    | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h
index 20febf0..254c395 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 1f3adf9..4a505b3 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);
-- 
GitLab