@SuppressWarnings("unchecked")
@Test
public void testCommitJobInterrupt() throws Exception {

  // Setup the sample directory.
  generateSampleFiles();
  // Setup the expected exception
  InterruptedException helperInterruptedException = new InterruptedException("Test exception");
  // Configure special case mock.
  doThrow(helperInterruptedException)
      .when(mockBigQueryHelper)
      .importFromGcs(
          any(String.class),
          any(TableReference.class),
          any(TableSchema.class),
          any(TimePartitioning.class),
          anyString(),
          any(BigQueryFileFormat.class),
          any(String.class),
          any(String.class),
          any(List.class),
          eq(true));
  IOException thrown = assertThrows(IOException.class, () -> committer.commitJob(job));
  assertThat(thrown).hasCauseThat().isEqualTo(helperInterruptedException);
  // Verify we're making the BigQuery import call.
  verify(mockBigQueryHelper)
      .importFromGcs(
          eq(TEST_PROJECT_ID),
          eq(outputTableRef),
          eq(TEST_TABLE_SCHEMA.get()),
          eq(TEST_TIME_PARTITIONING.get()),
          eq(TEST_KMS_KEY_NAME),
          eq(TEST_FILE_FORMAT),
          eq(TEST_CREATE_DISPOSITION),
          eq(TEST_WRITE_DISPOSITION),
          any(List.class), // Tested, no need to capture
          eq(true));
  // Verify the delegate is being called.
  verify(mockCommitter).commitJob(eq(job));
}