This is an automated email from the ASF dual-hosted git repository.
jackye pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new ef6b1daed3 Dell: remove usage of AssertHelpers (#7143)
ef6b1daed3 is described below
commit ef6b1daed30efd7efa4e8e4829c41700c51154fb
Author: Liu Xiao <[email protected]>
AuthorDate: Tue Mar 21 04:26:39 2023 +0800
Dell: remove usage of AssertHelpers (#7143)
---
.../apache/iceberg/dell/ecs/TestEcsCatalog.java | 39 +++++++++++-----------
.../apache/iceberg/dell/ecs/TestEcsOutputFile.java | 10 +++---
.../iceberg/dell/ecs/TestEcsTableOperations.java | 21 ++++++------
.../org/apache/iceberg/dell/ecs/TestEcsURI.java | 11 +++---
4 files changed, 39 insertions(+), 42 deletions(-)
diff --git a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsCatalog.java
b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsCatalog.java
index 1b26d23175..c61bd1db17 100644
--- a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsCatalog.java
+++ b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsCatalog.java
@@ -22,7 +22,6 @@ import static
org.apache.iceberg.types.Types.NestedField.required;
import java.io.IOException;
import java.util.Map;
-import org.apache.iceberg.AssertHelpers;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.HasTableOperations;
import org.apache.iceberg.Schema;
@@ -128,15 +127,13 @@ public class TestEcsCatalog {
ecsCatalog.createNamespace(Namespace.of("a", "b1"));
ecsCatalog.createTable(TableIdentifier.of("a", "t1"), SCHEMA);
- AssertHelpers.assertThrows(
- "Drop an unknown namespace should throw exception",
- NoSuchNamespaceException.class,
- () -> ecsCatalog.dropNamespace(Namespace.of("unknown")));
+ Assertions.assertThatThrownBy(() ->
ecsCatalog.dropNamespace(Namespace.of("unknown")))
+ .isInstanceOf(NoSuchNamespaceException.class)
+ .hasMessage("Namespace unknown does not exist");
- AssertHelpers.assertThrows(
- "Drop not empty namespace should throw exception",
- NamespaceNotEmptyException.class,
- () -> ecsCatalog.dropNamespace(Namespace.of("a")));
+ Assertions.assertThatThrownBy(() ->
ecsCatalog.dropNamespace(Namespace.of("a")))
+ .isInstanceOf(NamespaceNotEmptyException.class)
+ .hasMessage("Namespace a is not empty");
Assert.assertTrue("Drop namespace [a, b1]",
ecsCatalog.dropNamespace(Namespace.of("a", "b1")));
@@ -163,17 +160,19 @@ public class TestEcsCatalog {
ecsCatalog.createTable(TableIdentifier.of("a", "t1"), SCHEMA);
ecsCatalog.createNamespace(Namespace.of("b"));
- AssertHelpers.assertThrows(
- "Rename an unknown table should throw exception",
- NoSuchTableException.class,
- () -> ecsCatalog.renameTable(TableIdentifier.of("unknown"),
TableIdentifier.of("b", "t2")));
-
- AssertHelpers.assertThrows(
- "Rename to an unknown namespace should throw exception",
- NoSuchNamespaceException.class,
- () ->
- ecsCatalog.renameTable(
- TableIdentifier.of("a", "t1"), TableIdentifier.of("unknown",
"t2")));
+ Assertions.assertThatThrownBy(
+ () ->
+ ecsCatalog.renameTable(
+ TableIdentifier.of("unknown"), TableIdentifier.of("b",
"t2")))
+ .isInstanceOf(NoSuchTableException.class)
+ .hasMessage("Cannot rename table because table unknown does not
exist");
+
+ Assertions.assertThatThrownBy(
+ () ->
+ ecsCatalog.renameTable(
+ TableIdentifier.of("a", "t1"),
TableIdentifier.of("unknown", "t2")))
+ .isInstanceOf(NoSuchNamespaceException.class)
+ .hasMessage("Cannot rename a.t1 to unknown.t2 because namespace
unknown does not exist");
ecsCatalog.renameTable(TableIdentifier.of("a", "t1"),
TableIdentifier.of("b", "t2"));
diff --git
a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsOutputFile.java
b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsOutputFile.java
index 95c302bf3e..6d12a6aaa2 100644
--- a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsOutputFile.java
+++ b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsOutputFile.java
@@ -22,11 +22,11 @@ import com.emc.object.Range;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import org.apache.iceberg.AssertHelpers;
import org.apache.iceberg.dell.mock.ecs.EcsS3MockRule;
import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.io.PositionOutputStream;
import org.apache.iceberg.relocated.com.google.common.io.ByteStreams;
+import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
@@ -88,10 +88,8 @@ public class TestEcsOutputFile {
output.write("1234567890".getBytes());
}
- AssertHelpers.assertThrows(
- "Create should throw exception",
- AlreadyExistsException.class,
- outputFile.location(),
- outputFile::create);
+ Assertions.assertThatThrownBy(outputFile::create)
+ .isInstanceOf(AlreadyExistsException.class)
+ .hasMessage("ECS object already exists: " + outputFile.location());
}
}
diff --git
a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsTableOperations.java
b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsTableOperations.java
index 0bddc2515b..fca78ed7be 100644
--- a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsTableOperations.java
+++ b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsTableOperations.java
@@ -21,7 +21,6 @@ package org.apache.iceberg.dell.ecs;
import static org.apache.iceberg.types.Types.NestedField.required;
import java.util.Map;
-import org.apache.iceberg.AssertHelpers;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.HasTableOperations;
import org.apache.iceberg.Schema;
@@ -34,6 +33,7 @@ import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
@@ -57,15 +57,16 @@ public class TestEcsTableOperations {
// Use the TableOperations to test the CommitFailedException
// High level actions, such as Table#updateProperties(), may refresh
metadata.
TableOperations operations = ((HasTableOperations)
catalog2Table).operations();
- AssertHelpers.assertThrows(
- "Commit failed when use out-dated status",
- CommitFailedException.class,
- () ->
- operations.commit(
- operations.current(),
- TableMetadata.buildFrom(operations.current())
- .removeProperties(ImmutableSet.of("a"))
- .build()));
+ Assertions.assertThatThrownBy(
+ () ->
+ operations.commit(
+ operations.current(),
+ TableMetadata.buildFrom(operations.current())
+ .removeProperties(ImmutableSet.of("a"))
+ .build()))
+ .isInstanceOf(CommitFailedException.class)
+ .hasMessageStartingWith("Replace failed, E-Tag")
+ .hasMessageContaining("mismatch for table test2.t1");
}
public EcsCatalog createCatalog(String name) {
diff --git a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsURI.java
b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsURI.java
index 27ae70004f..9952ffd82b 100644
--- a/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsURI.java
+++ b/dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsURI.java
@@ -18,8 +18,8 @@
*/
package org.apache.iceberg.dell.ecs;
-import org.apache.iceberg.AssertHelpers;
import org.apache.iceberg.exceptions.ValidationException;
+import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Test;
@@ -54,10 +54,9 @@ public class TestEcsURI {
@Test
public void testInvalidLocation() {
- AssertHelpers.assertThrows(
- "Invalid location should cause exception",
- ValidationException.class,
- "http://bucket/a",
- () -> new EcsURI("http://bucket/a"));
+
+ Assertions.assertThatThrownBy(() -> new EcsURI("http://bucket/a"))
+ .isInstanceOf(ValidationException.class)
+ .hasMessage("Invalid ecs location: http://bucket/a");
}
}