Skip to content

Commit

Permalink
Use AssertJ for verifying exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Dec 28, 2017
1 parent 31fddf4 commit 5c21acb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions presto-hive-hadoop2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-hive</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions presto-hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.anarres.lzo</groupId>
<artifactId>lzo-hadoop</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<smallint,tinyint> 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<smallint,tinyint> not supported");
}
}

Expand Down

0 comments on commit 5c21acb

Please sign in to comment.