@Test
  public void testHiveSQLExceptionToTStatus() {
    String expectedMessage = "reason";
    String expectedSqlState = "sqlState";
    int expectedVendorCode = 10;

    Exception ex1 = new HiveSQLException(expectedMessage, expectedSqlState, expectedVendorCode, createSimpleCause());
    TStatus status = HiveSQLException.toTStatus(ex1);

    Assert.assertEquals(TStatusCode.ERROR_STATUS, status.getStatusCode());
    Assert.assertEquals(expectedSqlState, status.getSqlState());
    Assert.assertEquals(expectedMessage, status.getErrorMessage());
    Assert.assertEquals(HiveSQLException.DEFAULT_INFO, status.getInfoMessages());
  }
Tests the conversion from a HiveSQLException exception to the TStatus object
service/src/test/org/apache/hive/service/cli/TestHiveSQLException.java