Search in sources :

Example 1 with TDClientHttpConflictException

use of com.treasuredata.client.TDClientHttpConflictException in project fluency by komamitsu.

the class TreasureDataSenderTest method sendWithLackOfPermissionOnDatabase.

@Test
public void sendWithLackOfPermissionOnDatabase() throws IOException {
    doThrow(new TDClientHttpNotFoundException("Not Found!!!!")).when(client).importFile(anyString(), anyString(), any(File.class), anyString());
    doThrow(new TDClientHttpNotFoundException("Not Found!!!!")).when(client).createTable(anyString(), anyString());
    doThrow(new TDClientHttpConflictException("Conflict!!!!")).when(client).createDatabase(anyString());
    doReturn(false).when(client).existsDatabase(anyString());
    try {
        sender.send(DB_AND_TABLE, ByteBuffer.wrap(DATA));
        fail();
    } catch (NonRetryableException e) {
        assertTrue(true);
    }
    ArgumentCaptor<String> uniqueIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(client, times(1)).importFile(eq(DB), eq(TABLE), any(File.class), uniqueIdArgumentCaptor.capture());
    verify(client, times(4)).createDatabase(eq(DB));
    verify(client, times(4)).existsDatabase(eq(DB));
    verify(client, times(1)).createTable(eq(DB), eq(TABLE));
    UUID.fromString(uniqueIdArgumentCaptor.getValue());
}
Also used : NonRetryableException(org.komamitsu.fluency.NonRetryableException) TDClientHttpConflictException(com.treasuredata.client.TDClientHttpConflictException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) TDClientHttpNotFoundException(com.treasuredata.client.TDClientHttpNotFoundException) Test(org.junit.jupiter.api.Test)

Aggregations

TDClientHttpConflictException (com.treasuredata.client.TDClientHttpConflictException)1 TDClientHttpNotFoundException (com.treasuredata.client.TDClientHttpNotFoundException)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1 NonRetryableException (org.komamitsu.fluency.NonRetryableException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1