You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/02/23 02:58:23 UTC

[GitHub] [iceberg] happyprg commented on a change in pull request #4201: CORE - Initial basic API for the REST HTTP Client

happyprg commented on a change in pull request #4201:
URL: https://github.com/apache/iceberg/pull/4201#discussion_r812523976



##########
File path: core/src/test/java/org/apache/iceberg/rest/responses/TestErrorResponseParser.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.iceberg.rest.responses;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestErrorResponseParser {
+
+  @Test
+  public void testErrorResponseToJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+    ErrorResponse response = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    Assert.assertEquals("Should be able to serialize an error response as json",
+        ErrorResponseParser.toJson(response), json);
+  }
+
+  @Test
+  public void testErrorResponseFromJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+
+    ErrorResponse expected = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    assertEquals(expected, ErrorResponseParser.fromJson(json));
+  }
+
+  public void assertEquals(ErrorResponse expected, ErrorResponse actual) {
+    Assert.assertEquals("Message should be equal", expected.message(), actual.message());
+    Assert.assertEquals("Typ should be equal", expected.type(), actual.type());

Review comment:
       ```suggestion
       Assert.assertEquals("Type should be equal", expected.type(), actual.type());
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org