Skip to content

Commit

Permalink
Replace fail with assertThatThrownBy in TestHiveTypeTranslator
Browse files Browse the repository at this point in the history
Co-Authored-By: u7292105 <[email protected]>
  • Loading branch information
ebyhr and u7292105 committed Nov 1, 2024
1 parent fbb9610 commit 9933aac
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
});
}
}

0 comments on commit 9933aac

Please sign in to comment.