BigtableBufferedMutator implements BufferedMutator { @Override public void mutate(List<? extends Mutation> mutations) throws IOException { handleExceptions(); List<ApiFuture<?>> futures = helper.mutate(mutations); for (int i = 0; i < mutations.size(); i++) { addCallback(futures.get(i), mutations.get(i)); } } BigtableBufferedMutator(
      BigtableApi bigtableApi,
      BigtableHBaseSettings settings,
      HBaseRequestAdapter adapter,
      BufferedMutator.ExceptionListener listener); @Override void close(); @Override void flush(); @Override Configuration getConfiguration(); @Override TableName getName(); @Override long getWriteBufferSize(); @Override void mutate(List<? extends Mutation> mutations); @Override void mutate(Mutation mutation);  }
@Test public void testPut() throws IOException { when(mockBulkMutation.add(any(RowMutationEntry.class))).thenReturn(future); BigtableBufferedMutator underTest = createMutator(new Configuration(false)); underTest.mutate(SIMPLE_PUT); verify(mockBulkMutation, times(1)).add(any(RowMutationEntry.class)); }
@Test public void testDelete() throws IOException { when(mockBulkMutation.add(any(RowMutationEntry.class))).thenReturn(future); BigtableBufferedMutator underTest = createMutator(new Configuration(false)); underTest.mutate(new Delete(EMPTY_BYTES)); verify(mockBulkMutation, times(1)).add(any(RowMutationEntry.class)); }
@Test public void testIncrement() throws IOException { when(mockDataClient.readModifyWriteRowAsync(any(ReadModifyWriteRow.class))).thenReturn(future); BigtableBufferedMutator underTest = createMutator(new Configuration(false)); underTest.mutate(new Increment(EMPTY_BYTES).addColumn(EMPTY_BYTES, EMPTY_BYTES, 1)); verify(mockDataClient, times(1)).readModifyWriteRowAsync(any(ReadModifyWriteRow.class)); }
@Test public void testAppend() throws IOException { when(mockDataClient.readModifyWriteRowAsync(any(ReadModifyWriteRow.class))).thenReturn(future); BigtableBufferedMutator underTest = createMutator(new Configuration(false)); underTest.mutate(new Append(EMPTY_BYTES).add(EMPTY_BYTES, EMPTY_BYTES, EMPTY_BYTES)); verify(mockDataClient, times(1)).readModifyWriteRowAsync(any(ReadModifyWriteRow.class)); }
@Test public void testInvalidPut() throws Exception { when(mockBulkMutation.add(any(RowMutationEntry.class))) .thenReturn(ApiFutures.<Void>immediateFailedFuture(new RuntimeException())); BigtableBufferedMutator underTest = createMutator(new Configuration(false)); underTest.mutate(SIMPLE_PUT); verify(listener, times(0)) .onException(any(RetriesExhaustedWithDetailsException.class), same(underTest)); underTest.mutate(SIMPLE_PUT); verify(listener, times(1)) .onException(any(RetriesExhaustedWithDetailsException.class), same(underTest)); }