From 9664ee6ac31cb2c4f037930323bf01c7fcc1d0bc Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Mon, 16 Aug 2021 21:37:27 +0200
Subject: [PATCH] WIP: consolidation

---
 .../download_request_handler.cpp              | 21 ++++++------
 src/caosdb/transaction.cpp                    | 32 ++++++++-----------
 test/test_data_type.cpp                       | 16 +++++++---
 test/test_entity.cpp                          | 27 +++++++---------
 test/test_protobuf.cpp                        | 11 ++++---
 test/test_value.cpp                           |  6 ++--
 6 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/src/caosdb/file_transmission/download_request_handler.cpp b/src/caosdb/file_transmission/download_request_handler.cpp
index fb36ca5..db4769b 100644
--- a/src/caosdb/file_transmission/download_request_handler.cpp
+++ b/src/caosdb/file_transmission/download_request_handler.cpp
@@ -59,16 +59,17 @@
 #include <boost/preprocessor/seq/limits/size_256.hpp>  // for BOOST_PP_SEQ_...
 #include <exception>                                   // IWYU pragma: keep
 // IWYU pragma: no_include <bits/exception.h>
-#include <google/protobuf/arena.h>                // for Arena
-#include <grpcpp/impl/codegen/async_stream.h>     // for ClientAsyncRe...
-#include <grpcpp/impl/codegen/client_context.h>   // for ClientContext
-#include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue
-#include <grpcpp/impl/codegen/status.h>           // for Status
-#include <grpcpp/impl/codegen/status_code_enum.h> // for OK, UNAUTHENT...
-#include <iostream>                               // for char_traits
-#include <stdexcept>                              // for runtime_error
-#include <string>                                 // for string, opera...
-#include <utility>                                // for move
+#include <google/protobuf/arena.h>                  // for Arena
+#include <google/protobuf/generated_message_util.h> // for Arena
+#include <grpcpp/impl/codegen/async_stream.h>       // for ClientAsyncRe...
+#include <grpcpp/impl/codegen/client_context.h>     // for ClientContext
+#include <grpcpp/impl/codegen/completion_queue.h>   // for CompletionQueue
+#include <grpcpp/impl/codegen/status.h>             // for Status
+#include <grpcpp/impl/codegen/status_code_enum.h>   // for OK, UNAUTHENT...
+#include <iostream>                                 // for char_traits
+#include <stdexcept>                                // for runtime_error
+#include <string>                                   // for string, opera...
+#include <utility>                                  // for move
 
 namespace caosdb::transaction {
 using caosdb::StatusCode;
diff --git a/src/caosdb/transaction.cpp b/src/caosdb/transaction.cpp
index 7732136..ac64e26 100644
--- a/src/caosdb/transaction.cpp
+++ b/src/caosdb/transaction.cpp
@@ -22,15 +22,14 @@
 #include "caosdb/entity/v1alpha1/main.pb.h"      // for TransactionRe...
 #include "caosdb/file_transmission/download_request_handler.h" // Download...
 #include "caosdb/file_transmission/file_reader.h"              // for path
-#include "caosdb/file_transmission/register_file_upload_handler.h"
+#include "caosdb/file_transmission/register_file_upload_handler.h" // for RegisterFileUploadHandler
 #include "caosdb/file_transmission/upload_request_handler.h" // Upload...
-#include "caosdb/logging.h" // for CAOSDB_LOG_FATAL
-#include "caosdb/protobuf_helper.h"
-#include "caosdb/status_code.h" // for StatusCode
-#include "caosdb/transaction_handler.h"
-#include <algorithm>                                   // for max
-#include <boost/filesystem/path.hpp>                   // for operator<<, path
-#include <boost/log/core/record.hpp>                   // for record
+#include "caosdb/logging.h"             // for CAOSDB_LOG_FATAL
+#include "caosdb/status_code.h"         // for StatusCode
+#include "caosdb/transaction_handler.h" // for EntityTransactionHandler
+#include <algorithm>                    // for max
+#include <boost/filesystem/path.hpp>    // for operator<<, path
+#include <boost/log/core/record.hpp>    // for record
 #include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostring...
 #include <boost/log/sources/record_ostream.hpp>        // for basic_record_...
 #include <boost/preprocessor/seq/limits/enum_256.hpp>  // for BOOST_PP_SEQ_...
@@ -39,14 +38,13 @@
 #include <exception>                                // IWYU pragma: keep
 #include <google/protobuf/arena.h>                  // for Arena
 #include <google/protobuf/generated_message_util.h> // for CreateMessage...
-#include <google/protobuf/util/json_util.h>
-#include <grpc/impl/codegen/gpr_types.h>
-#include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue
-#include <iosfwd>                                 // for streamsize
-#include <map>                                    // for map, operator!=
-#include <memory>                                 // for unique_ptr
-#include <stdexcept>                              // for out_of_range
-#include <utility>                                // for move, pair
+#include <grpc/impl/codegen/gpr_types.h>            // for gpr_timespec
+#include <grpcpp/impl/codegen/completion_queue.h>   // for CompletionQueue
+#include <iosfwd>                                   // for streamsize
+#include <map>                                      // for map, operator!=
+#include <memory>                                   // for unique_ptr
+#include <stdexcept>                                // for out_of_range
+#include <utility>                                  // for move, pair
 
 namespace caosdb {
 
@@ -232,8 +230,6 @@ auto Transaction::InsertEntity(Entity *entity) noexcept -> StatusCode {
 
   // copy the original entity for the transaction
   entity->CopyTo(proto_entity);
-  CAOSDB_DEBUG_MESSAGE_STRING(*proto_entity, out);
-  CAOSDB_LOG_DEBUG(logger_name) << "INSERT ENTITY: " << out;
   if (entity->HasFile()) {
     auto *file_transmission_id = entity_request->mutable_upload_id();
     entity->SetFileTransmissionId(file_transmission_id);
diff --git a/test/test_data_type.cpp b/test/test_data_type.cpp
index b57c4b2..9ab4ac0 100644
--- a/test/test_data_type.cpp
+++ b/test/test_data_type.cpp
@@ -23,10 +23,18 @@
 #include "caosdb/data_type.h"               // for DataType, AtomicDataType
 #include "caosdb/entity.h"                  // for Entity
 #include "caosdb/entity/v1alpha1/main.pb.h" // for AtomicDataType, DataType
-#include <gtest/gtest-message.h>            // for Message
-#include <gtest/gtest-test-part.h>          // for TestPartResult, SuiteApi...
-#include <gtest/gtest_pred_impl.h>          // for AssertionResult, Test
-#include <memory>                           // for allocator
+#include "caosdb/logging.h"                 // for CAOSDB_LOG_DEBUG
+#include "caosdb/protobuf_helper.h"         // for CAOSDB_DEBUG_...
+#include <boost/log/core/record.hpp>        // for record
+#include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostring...
+#include <boost/log/sources/record_ostream.hpp>        // for operator<<
+#include <boost/preprocessor/seq/limits/enum_256.hpp>  // for BOOST_PP_SEQ_...
+#include <boost/preprocessor/seq/limits/size_256.hpp>  // for BOOST_PP_SEQ_...
+#include <gtest/gtest-message.h>                       // for Message
+#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApi...
+#include <gtest/gtest_pred_impl.h> // for AssertionResult, Test
+#include <iosfwd>                  // for streamsize
+#include <string>                  // for allocator
 
 namespace caosdb::entity {
 using ProtoEntity = caosdb::entity::v1alpha1::Entity;
diff --git a/test/test_entity.cpp b/test/test_entity.cpp
index 634e3c4..f38f144 100644
--- a/test/test_entity.cpp
+++ b/test/test_entity.cpp
@@ -25,20 +25,15 @@
 #include "caosdb/entity.h"                       // for Entity, Parent, Par...
 #include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for EntityTransactionSe...
 #include "caosdb/entity/v1alpha1/main.pb.h"      // for IdResponse, Message
-#include "caosdb/logging.h"
-#include "caosdb/message_code.h"                // for MessageCode
-#include "caosdb/protobuf_helper.h"             // for get_arena
-#include "caosdb/status_code.h"                 // for StatusCode, FILE_DO...
-#include "caosdb/transaction.h"                 // for Transaction
-#include "caosdb/value.h"                       // for Value
-#include <boost/log/core/record.hpp>            // for record
-#include <boost/log/sources/record_ostream.hpp> // for record_pump<>:...
-#include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_E...
-#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_S...
-#include <google/protobuf/arena.h>                    // for Arena
-#include <gtest/gtest-message.h>                      // for Message
-#include <gtest/gtest-test-part.h> // for TestPartResult, Sui...
-#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ
+#include "caosdb/message_code.h"                 // for MessageCode
+#include "caosdb/protobuf_helper.h"              // for get_arena
+#include "caosdb/status_code.h"                  // for StatusCode, FILE_DO...
+#include "caosdb/transaction.h"                  // for Transaction
+#include "caosdb/value.h"                        // for Value
+#include <google/protobuf/arena.h>               // for Arena
+#include <gtest/gtest-message.h>                 // for Message
+#include <gtest/gtest-test-part.h>               // for TestPartResult, Sui...
+#include <gtest/gtest_pred_impl.h>               // for Test, EXPECT_EQ
 #include <iostream>
 #include <memory> // for allocator, shared_ptr
 #include <string> // for operator+, string
@@ -105,7 +100,7 @@ TEST(test_entity, test_append_property) {
   entity.AppendProperty(prop);
   EXPECT_EQ(entity.GetProperties().size(), 1);
 
-  auto &same_prop = entity.GetProperties().at(0);
+  const auto &same_prop = entity.GetProperties().at(0);
 
   EXPECT_EQ(prop.GetName(), same_prop.GetName());
   EXPECT_EQ(prop.GetId(), same_prop.GetId());
@@ -233,7 +228,7 @@ TEST(test_entity, test_insert_with_property) {
 
   EXPECT_EQ(entity.GetProperties().size(), 1);
 
-  auto &inserted_prop = entity.GetProperties().at(0);
+  const auto &inserted_prop = entity.GetProperties().at(0);
 
   EXPECT_EQ(prop.GetName(), inserted_prop.GetName());
   EXPECT_EQ(prop.GetId(), inserted_prop.GetId());
diff --git a/test/test_protobuf.cpp b/test/test_protobuf.cpp
index afe4b30..48cfd23 100644
--- a/test/test_protobuf.cpp
+++ b/test/test_protobuf.cpp
@@ -19,12 +19,13 @@
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  *
  */
+#include "caosdb/data_type.h"               // for DataType, ReferenceDataType
+#include "caosdb/entity.h"                  // for Entity
 #include "caosdb/entity/v1alpha1/main.pb.h" // for RepeatedPtrField, Message
-#include "caosdb/entity.h"
-#include "gtest/gtest-message.h"   // for Message
-#include "gtest/gtest-test-part.h" // for SuiteApiResolver, TestPa...
-#include "gtest/gtest_pred_impl.h" // for Test, TestInfo, TEST
-#include <memory>                  // for allocator
+#include <gtest/gtest-message.h>            // for Message
+#include <gtest/gtest-test-part.h>          // for SuiteApiResolver, TestPa...
+#include <gtest/gtest_pred_impl.h>          // for Test, TestInfo, TEST
+#include <memory>                           // for allocator
 
 namespace caosdb {
 using ProtoEntity = caosdb::entity::v1alpha1::Entity;
diff --git a/test/test_value.cpp b/test/test_value.cpp
index 890922e..39a6ac4 100644
--- a/test/test_value.cpp
+++ b/test/test_value.cpp
@@ -21,13 +21,15 @@
  */
 
 #include "caosdb/value.h"                   // for Value
-#include "caosdb/entity.h"                  // for Entity
 #include "caosdb/entity/v1alpha1/main.pb.h" // for AtomicDataType, DataType
+#include <algorithm>                        // for max
 #include <cmath>                            // for isnan
 #include <gtest/gtest-message.h>            // for Message
 #include <gtest/gtest-test-part.h>          // for TestPartResult, SuiteApi...
 #include <gtest/gtest_pred_impl.h>          // for AssertionResult, Test
-#include <memory>                           // for allocator
+#include <initializer_list>                 // for initializer_list
+#include <string>                           // for string, basic_string
+#include <vector>                           // for vector
 
 namespace caosdb::entity {
 using ProtoEntity = caosdb::entity::v1alpha1::Entity;
-- 
GitLab