dimas-b commented on code in PR #3729:
URL: https://github.com/apache/polaris/pull/3729#discussion_r2906735937
##########
polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java:
##########
@@ -182,7 +182,8 @@ public static ConnectionConfigInfoDpo
fromConnectionConfigInfoModelWithSecrets(
icebergRestConfigModel.getUri(),
authenticationParameters,
null /*Service Identity Info*/,
- icebergRestConfigModel.getRemoteCatalogName());
+ icebergRestConfigModel.getRemoteCatalogName(),
+ icebergRestConfigModel.getAdditionalHeaders());
Review Comment:
This does not appear to be passed back to API responses
(`asConnectionConfigInfoModel`), so we apparently do not have a complete data
roundtrip 🤔
##########
polaris-core/src/test/java/org/apache/polaris/core/connection/GcpAuthenticationParametersDpoTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.polaris.core.connection;
+
+import static java.util.stream.Collectors.toUnmodifiableSet;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+import org.apache.polaris.core.admin.model.GcpAuthenticationParameters;
+import
org.apache.polaris.core.connection.iceberg.IcebergRestConnectionConfigInfoDpo;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class GcpAuthenticationParametersDpoTest {
+
+ private GcpAuthenticationParametersDpo dpo;
+
+ @BeforeEach
+ void setUp() {
+ dpo = new GcpAuthenticationParametersDpo();
+ }
+
+ @Test
+ void testSerializeAndDeserialize() throws Exception {
+ var connectionConfig =
+ new IcebergRestConnectionConfigInfoDpo(
+ "https://biglake.googleapis.com/iceberg/v1/restcatalog", dpo,
null, null, Map.of());
+
+ assertEquals(
+ connectionConfig.toString(),
+
ConnectionConfigInfoDpo.deserialize(connectionConfig.serialize()).toString());
+ }
+
+ @Test
+ void testConversionToDTOCapturesAllFields() {
+ GcpAuthenticationParameters authenticationParameters =
dpo.asAuthenticationParametersModel();
+ Set<String> dtoGetMethods =
+ Arrays.stream(GcpAuthenticationParameters.class.getDeclaredMethods())
+ .map(Method::getName)
+ .filter(x -> x.startsWith("get"))
+ .collect(toUnmodifiableSet());
+ dtoGetMethods.stream()
+ .forEach(
+ x -> {
+ try {
+ var expected =
GcpAuthenticationParametersDpo.class.getMethod(x, null).invoke(dpo);
Review Comment:
IJ flags the `null` parameter as "confusing" (warning: `Confusing argument
'null', unclear if a varargs or non-varargs call is desired`)
##########
polaris-core/src/main/java/org/apache/polaris/core/connection/iceberg/IcebergRestConnectionConfigInfoDpo.java:
##########
@@ -43,19 +43,34 @@
public class IcebergRestConnectionConfigInfoDpo extends ConnectionConfigInfoDpo
implements IcebergCatalogPropertiesProvider {
+ private static final String GOOGLE_USER_PROJECT_HEADER_KEY =
"x-goog-user-project";
+
private final String remoteCatalogName;
+ @Nullable
+ public Map<String, String> getConfigs() {
Review Comment:
could you move methods below constructors (usual pattern in Polaris)?
##########
polaris-core/src/test/java/org/apache/polaris/core/connection/GcpAuthenticationParametersDpoTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.polaris.core.connection;
+
+import static java.util.stream.Collectors.toUnmodifiableSet;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+import org.apache.polaris.core.admin.model.GcpAuthenticationParameters;
+import
org.apache.polaris.core.connection.iceberg.IcebergRestConnectionConfigInfoDpo;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class GcpAuthenticationParametersDpoTest {
+
+ private GcpAuthenticationParametersDpo dpo;
+
+ @BeforeEach
+ void setUp() {
+ dpo = new GcpAuthenticationParametersDpo();
+ }
+
+ @Test
+ void testSerializeAndDeserialize() throws Exception {
+ var connectionConfig =
+ new IcebergRestConnectionConfigInfoDpo(
+ "https://biglake.googleapis.com/iceberg/v1/restcatalog", dpo,
null, null, Map.of());
+
+ assertEquals(
+ connectionConfig.toString(),
+
ConnectionConfigInfoDpo.deserialize(connectionConfig.serialize()).toString());
+ }
+
+ @Test
+ void testConversionToDTOCapturesAllFields() {
+ GcpAuthenticationParameters authenticationParameters =
dpo.asAuthenticationParametersModel();
+ Set<String> dtoGetMethods =
+ Arrays.stream(GcpAuthenticationParameters.class.getDeclaredMethods())
+ .map(Method::getName)
+ .filter(x -> x.startsWith("get"))
+ .collect(toUnmodifiableSet());
+ dtoGetMethods.stream()
+ .forEach(
+ x -> {
+ try {
+ var expected =
GcpAuthenticationParametersDpo.class.getMethod(x, null).invoke(dpo);
+ var actual =
+ GcpAuthenticationParameters.class
+ .getMethod(x, null)
+ .invoke(authenticationParameters);
+ assertEquals(expected, actual);
Review Comment:
Would you mind switching to AssertJ? It is generally used in newer tests in
Polaris.
##########
polaris-core/src/test/java/org/apache/polaris/core/connection/GcpAuthenticationParametersDpoTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.polaris.core.connection;
+
+import static java.util.stream.Collectors.toUnmodifiableSet;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+import org.apache.polaris.core.admin.model.GcpAuthenticationParameters;
+import
org.apache.polaris.core.connection.iceberg.IcebergRestConnectionConfigInfoDpo;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class GcpAuthenticationParametersDpoTest {
+
+ private GcpAuthenticationParametersDpo dpo;
+
+ @BeforeEach
+ void setUp() {
+ dpo = new GcpAuthenticationParametersDpo();
+ }
+
+ @Test
+ void testSerializeAndDeserialize() throws Exception {
+ var connectionConfig =
+ new IcebergRestConnectionConfigInfoDpo(
+ "https://biglake.googleapis.com/iceberg/v1/restcatalog", dpo,
null, null, Map.of());
+
+ assertEquals(
+ connectionConfig.toString(),
+
ConnectionConfigInfoDpo.deserialize(connectionConfig.serialize()).toString());
+ }
+
+ @Test
+ void testConversionToDTOCapturesAllFields() {
+ GcpAuthenticationParameters authenticationParameters =
dpo.asAuthenticationParametersModel();
+ Set<String> dtoGetMethods =
+ Arrays.stream(GcpAuthenticationParameters.class.getDeclaredMethods())
+ .map(Method::getName)
+ .filter(x -> x.startsWith("get"))
+ .collect(toUnmodifiableSet());
+ dtoGetMethods.stream()
Review Comment:
(minor) Please consider test factories. I hope it will result in more
user-friendly test reports (especially in case of failures).
Cf. #3824
--
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]