From 9933aaca7e7850b07e01bd5fb77c120361be2d8f Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Fri, 1 Nov 2024 18:51:46 +0900 Subject: [PATCH] Replace fail with assertThatThrownBy in TestHiveTypeTranslator Co-Authored-By: u7292105 <177819449+u7292105@users.noreply.github.com> --- .../hive/util/TestHiveTypeTranslator.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java index 4ea1ff625d416..3057eb7e36d2b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java @@ -44,7 +44,7 @@ import static io.trino.spi.type.VarcharType.createVarcharType; import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Fail.fail; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class TestHiveTypeTranslator { @@ -83,19 +83,12 @@ private static void assertTypeTranslation(Type type, HiveType hiveType) private static void assertInvalidTypeTranslation(Type type, ErrorCode errorCode, String message) { - try { - toHiveType(type); - fail("expected exception"); - } - catch (TrinoException e) { - try { - assertThat(e.getErrorCode()).isEqualTo(errorCode); - assertThat(e).hasMessageContaining(message); - } - catch (Throwable failure) { - failure.addSuppressed(e); - throw failure; - } - } + assertThatThrownBy(() -> toHiveType(type)) + .isInstanceOf(TrinoException.class) + .satisfies(e -> { + TrinoException trinoException = (TrinoException) e; + assertThat(trinoException.getErrorCode()).isEqualTo(errorCode); + assertThat(trinoException).hasMessageContaining(message); + }); } }