use of com.treasuredata.client.TDClientHttpNotFoundException in project fluency by komamitsu.
the class TreasureDataSenderTest method sendWithCreatingTable.
@Test
void sendWithCreatingTable() throws IOException {
AtomicInteger importToTableCalls = new AtomicInteger();
doAnswer(invocation -> {
if (importToTableCalls.getAndIncrement() == 0) {
throw new TDClientHttpNotFoundException("Not Found!!!!");
}
assertImportedFile(invocation.getArgument(2));
return null;
}).when(client).importFile(anyString(), anyString(), any(File.class), anyString());
sender.send(DB_AND_TABLE, ByteBuffer.wrap(DATA));
ArgumentCaptor<String> uniqueIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(client, times(2)).importFile(eq(DB), eq(TABLE), any(File.class), uniqueIdArgumentCaptor.capture());
verify(client, times(0)).createDatabase(anyString());
verify(client, times(1)).createTable(eq(DB), eq(TABLE));
UUID.fromString(uniqueIdArgumentCaptor.getValue());
}
use of com.treasuredata.client.TDClientHttpNotFoundException 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());
}
use of com.treasuredata.client.TDClientHttpNotFoundException in project fluency by komamitsu.
the class TreasureDataSenderTest method sendWithCreatingDatabase.
@Test
void sendWithCreatingDatabase() throws IOException {
AtomicInteger importToTableCalls = new AtomicInteger();
doAnswer(invocation -> {
if (importToTableCalls.getAndIncrement() == 0) {
throw new TDClientHttpNotFoundException("Not Found!!!!");
}
assertImportedFile(invocation.getArgument(2));
return null;
}).when(client).importFile(anyString(), anyString(), any(File.class), anyString());
AtomicInteger createTableCalls = new AtomicInteger();
doAnswer(invocation -> {
if (createTableCalls.getAndIncrement() == 0) {
throw new TDClientHttpNotFoundException("Not Found!!!!");
}
return null;
}).when(client).createTable(anyString(), anyString());
sender.send(DB_AND_TABLE, ByteBuffer.wrap(DATA));
ArgumentCaptor<String> uniqueIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(client, times(2)).importFile(eq(DB), eq(TABLE), any(File.class), uniqueIdArgumentCaptor.capture());
verify(client, times(1)).createDatabase(eq(DB));
verify(client, times(2)).createTable(eq(DB), eq(TABLE));
UUID.fromString(uniqueIdArgumentCaptor.getValue());
}
Aggregations