### Question:
HiveWriter { protected StreamingConnection newConnection(HiveEndPoint endPoint, boolean autoCreatePartitions, HiveConf conf, UserGroupInformation ugi) throws InterruptedException, ConnectFailure { try { return callWithTimeout(() -> { return endPoint.newConnection(autoCreatePartitions, conf, ugi); }); } catch (StreamingException | TimeoutException e) { throw new ConnectFailure(endPoint, e); } } HiveWriter(HiveEndPoint endPoint, int txnsPerBatch, boolean autoCreatePartitions, long callTimeout, ExecutorService callTimeoutPool, UserGroupInformation ugi, HiveConf hiveConf); @Override String toString(); synchronized void write(final byte[] record); void flush(boolean rollToNext); void heartBeat(); int getTotalRecords(); void flushAndClose(); void close(); void abort(); long getLastUsed();  }### Answer:
@Test(expected = HiveWriter.ConnectFailure.class) public void testNewConnectionInvalidTable() throws Exception { hiveEndPoint = mock(HiveEndPoint.class); InvalidTable invalidTable = new InvalidTable("badDb", "badTable"); when(hiveEndPoint.newConnection(autoCreatePartitions, hiveConf, userGroupInformation)).thenThrow(invalidTable); try { initWriter(); } catch (HiveWriter.ConnectFailure e) { assertEquals(invalidTable, e.getCause()); throw e; } }