From 5c21acbed6860b74e9ee3c8f247006d98c3c8266 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 27 Dec 2017 20:43:18 -0800 Subject: [PATCH] Use AssertJ for verifying exception message --- presto-hive-hadoop2/pom.xml | 6 ++++++ presto-hive/pom.xml | 6 ++++++ .../com/facebook/presto/hive/AbstractTestHiveClient.java | 8 ++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/presto-hive-hadoop2/pom.xml b/presto-hive-hadoop2/pom.xml index 438f8e42c58dd..b79f85e655f9a 100644 --- a/presto-hive-hadoop2/pom.xml +++ b/presto-hive-hadoop2/pom.xml @@ -72,6 +72,12 @@ test + + org.assertj + assertj-core + test + + com.facebook.presto presto-hive diff --git a/presto-hive/pom.xml b/presto-hive/pom.xml index 20ee25895ba5c..361dcfb3dcb49 100644 --- a/presto-hive/pom.xml +++ b/presto-hive/pom.xml @@ -254,6 +254,12 @@ test + + org.assertj + assertj-core + test + + org.anarres.lzo lzo-hadoop diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java index 64d0e670321dc..530103007b416 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java @@ -103,7 +103,6 @@ import org.apache.hadoop.hive.metastore.TableType; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.testng.TestException; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -209,6 +208,7 @@ import static java.util.concurrent.Executors.newFixedThreadPool; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; import static org.joda.time.DateTimeZone.UTC; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -2445,11 +2445,7 @@ private void doInsertUnsupportedWriteType(HiveStorageFormat storageFormat, Schem fail("expected failure"); } catch (PrestoException e) { - String expected = "Inserting into Hive table .* with column type uniontype not supported"; - if (!e.getMessage().matches(expected)) { - throw new TestException("The exception was thrown with the wrong message:" + - " expected \"" + expected + "\"" + " but got \"" + e.getMessage() + "\"", e); - } + assertThat(e).hasMessageMatching("Inserting into Hive table .* with column type uniontype not supported"); } }