adutra commented on code in PR #598:
URL: https://github.com/apache/polaris/pull/598#discussion_r1900736168


##########
dropwizard/service/src/test/java/org/apache/polaris/service/dropwizard/IcebergExceptionMapperTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.service.dropwizard;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.azure.core.exception.AzureException;
+import com.google.cloud.storage.StorageException;
+import jakarta.ws.rs.core.Response;
+import java.util.stream.Stream;
+import org.apache.polaris.service.exception.IcebergExceptionMapper;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import software.amazon.awssdk.services.s3.model.S3Exception;
+
+class IcebergExceptionMapperTest {
+
+  static Stream<Arguments> fileIOExceptionMapping() {
+    return Stream.of(
+        Arguments.of(new AzureException("Unknown"), 500),
+        Arguments.of(new AzureException("Forbidden"), 403),
+        Arguments.of(new AzureException("FORBIDDEN"), 403),
+        Arguments.of(new AzureException("Not Authorized"), 403),
+        Arguments.of(new AzureException("Access Denied"), 403),
+        Arguments.of(S3Exception.builder().message("Access denied").build(), 
403),
+        Arguments.of(new StorageException(1, "access denied"), 403));

Review Comment:
   While at it, wdyt about adding the missing test cases?
   
   ```suggestion
           Arguments.of(new NoSuchNamespaceException("Unknown"), 404),
           Arguments.of(new NoSuchIcebergTableException("Unknown"), 404),
           Arguments.of(new NoSuchTableException("Unknown"), 404),
           Arguments.of(new NoSuchViewException("Unknown"), 404),
           Arguments.of(new NotFoundException("Unknown"), 404),
           Arguments.of(new AlreadyExistsException("Unknown"), 409),
           Arguments.of(new CommitFailedException("Unknown"), 409),
           Arguments.of(new UnprocessableEntityException("Unknown"), 422),
           Arguments.of(new CherrypickAncestorCommitException(123L), 400),
           Arguments.of(new CommitStateUnknownException("Unknown", new 
RuntimeException()), 400),
           Arguments.of(new DuplicateWAPCommitException("Unknown"), 400),
           Arguments.of(new ForbiddenException("Unknown"), 403),
           Arguments.of(new jakarta.ws.rs.ForbiddenException("Unknown"), 403),
           Arguments.of(new NotAuthorizedException("Unknown"), 401),
           Arguments.of(new NamespaceNotEmptyException("Unknown"), 400),
           Arguments.of(new ValidationException("Unknown"), 400),
           Arguments.of(new ServiceUnavailableException("Unknown"), 503),
           Arguments.of(new RuntimeIOException("Unknown"), 503),
           Arguments.of(new ServiceUnavailableException("Unknown"), 503),
           Arguments.of(new RESTException("Unknown"), 503),
           Arguments.of(new IllegalArgumentException("Unknown"), 400),
           Arguments.of(new UnsupportedOperationException("Unknown"), 406),
           Arguments.of(S3Exception.builder().message("Unknown").build(), 500),
           Arguments.of(S3Exception.builder().message("Forbidden").build(), 
403),
           Arguments.of(S3Exception.builder().message("FORBIDDEN").build(), 
403),
           Arguments.of(S3Exception.builder().message("Not 
Authorized").build(), 403),
           Arguments.of(S3Exception.builder().message("Access Denied").build(), 
403),
           Arguments.of(
               S3Exception.builder()
                   .message("Unknown")
                   .cause(new RuntimeException("Forbidden"))
                   .build(),
               403),
           Arguments.of(new AzureException("Unknown"), 500),
           Arguments.of(new AzureException("Forbidden"), 403),
           Arguments.of(new AzureException("FORBIDDEN"), 403),
           Arguments.of(new AzureException("Not Authorized"), 403),
           Arguments.of(new AzureException("Access Denied"), 403),
           Arguments.of(new AzureException("Unknown", new 
RuntimeException("Forbidden")), 403),
           Arguments.of(new StorageException(1, "Unknown"), 500),
           Arguments.of(new StorageException(1, "Forbidden"), 403),
           Arguments.of(new StorageException(1, "FORBIDDEN"), 403),
           Arguments.of(new StorageException(1, "Not Authorized"), 403),
           Arguments.of(new StorageException(1, "Access Denied"), 403),
           Arguments.of(new StorageException(1, "Unknown", new 
RuntimeException("Forbidden")), 403));
   ```



-- 
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]

Reply via email to