wgtmac commented on code in PR #251:
URL: https://github.com/apache/iceberg-cpp/pull/251#discussion_r2464485327


##########
src/iceberg/test/rest_json_internal_test.cc:
##########
@@ -0,0 +1,664 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <nlohmann/json.hpp>
+
+#include "iceberg/catalog/rest/json_internal.h"
+#include "iceberg/partition_spec.h"
+#include "iceberg/schema.h"
+#include "iceberg/snapshot.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/transform.h"
+#include "matchers.h"
+
+namespace iceberg::rest {
+
+namespace {
+
+// Helper templates for type-specific deserialization
+template <typename T>
+Result<T> FromJsonHelper(const nlohmann::json& json);
+
+template <>
+Result<CreateNamespaceRequest> FromJsonHelper<CreateNamespaceRequest>(
+    const nlohmann::json& j) {
+  return CreateNamespaceRequestFromJson(j);
+}
+
+template <>
+Result<UpdateNamespacePropertiesRequest> 
FromJsonHelper<UpdateNamespacePropertiesRequest>(
+    const nlohmann::json& j) {
+  return UpdateNamespacePropertiesRequestFromJson(j);
+}
+
+template <>
+Result<CreateTableRequest> FromJsonHelper<CreateTableRequest>(const 
nlohmann::json& j) {
+  return CreateTableRequestFromJson(j);
+}
+
+template <>
+Result<RegisterTableRequest> FromJsonHelper<RegisterTableRequest>(
+    const nlohmann::json& j) {
+  return RegisterTableRequestFromJson(j);
+}
+
+template <>
+Result<RenameTableRequest> FromJsonHelper<RenameTableRequest>(const 
nlohmann::json& j) {
+  return RenameTableRequestFromJson(j);
+}
+
+template <>
+Result<LoadTableResult> FromJsonHelper<LoadTableResult>(const nlohmann::json& 
j) {
+  return LoadTableResultFromJson(j);
+}
+
+template <>
+Result<ListNamespacesResponse> FromJsonHelper<ListNamespacesResponse>(
+    const nlohmann::json& j) {
+  return ListNamespacesResponseFromJson(j);
+}
+
+template <>
+Result<CreateNamespaceResponse> FromJsonHelper<CreateNamespaceResponse>(
+    const nlohmann::json& j) {
+  return CreateNamespaceResponseFromJson(j);
+}
+
+template <>
+Result<GetNamespaceResponse> FromJsonHelper<GetNamespaceResponse>(
+    const nlohmann::json& j) {
+  return GetNamespaceResponseFromJson(j);
+}
+
+template <>
+Result<UpdateNamespacePropertiesResponse>
+FromJsonHelper<UpdateNamespacePropertiesResponse>(const nlohmann::json& j) {
+  return UpdateNamespacePropertiesResponseFromJson(j);
+}
+
+template <>
+Result<ListTablesResponse> FromJsonHelper<ListTablesResponse>(const 
nlohmann::json& j) {
+  return ListTablesResponseFromJson(j);
+}
+
+// Test helper functions
+template <typename T>
+void TestJsonRoundTrip(const T& obj) {
+  auto j = ToJson(obj);
+  auto parsed = FromJsonHelper<T>(j);
+  ASSERT_TRUE(parsed.has_value()) << parsed.error().message;
+  auto j2 = ToJson(parsed.value());
+  EXPECT_EQ(j, j2) << "Round-trip JSON mismatch.";
+}
+
+template <typename T>
+void TestJsonConversion(const T& obj, const nlohmann::json& expected_json) {

Review Comment:
   What's the difference of this function compared to the above?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to