HBaseMutationAdapter extends MutationAdapter<Mutation> { @Override public void adapt( Mutation mutation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutationModel) { MutationAdapter<Mutation> adapter = adapterMap.get(mutation.getClass()); if (adapter == null) { throw new UnsupportedOperationException( String.format( "Cannot adapt mutation of type %s.", mutation.getClass().getCanonicalName())); } adapter.adapt(mutation, mutationModel); } HBaseMutationAdapter(
      MutationAdapter<Delete> deleteAdapter,
      MutationAdapter<Put> putAdapter,
      MutationAdapter<Increment> incrementAdapter,
      MutationAdapter<Append> appendAdapter); @Override void adapt(
      Mutation mutation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutationModel);  }
@Test public void testPutIsAdapted() { Put put = new Put(dataHelper.randomData("rk1")); adapter.adapt(put, mutation); Mockito.verify(putAdapter, Mockito.times(1)) .adapt(Mockito.any(Put.class), Mockito.eq(mutation)); }
@Test public void testDeleteIsAdapted() { Delete delete = new Delete(dataHelper.randomData("rk1")); adapter.adapt(delete, mutation); Mockito.verify(deleteAdapter, Mockito.times(1)) .adapt(Mockito.any(Delete.class), Mockito.eq(mutation)); }
@Test public void testAppendIsAdapted() { Append append = new Append(dataHelper.randomData("rk1")); adapter.adapt(append, mutation); Mockito.verify(appendAdapter, Mockito.times(1)) .adapt(Mockito.any(Append.class), Mockito.eq(mutation)); }
@Test public void testIncrementIsAdapted() { Increment increment = new Increment(dataHelper.randomData("rk1")); adapter.adapt(increment, mutation); Mockito.verify(incrementAdapter, Mockito.times(1)) .adapt(Mockito.any(Increment.class), Mockito.eq(mutation)); }
@Test public void exceptionIsThrownOnUnknownMutation() { UnknownMutation unknownMutation = new UnknownMutation(); expectedException.expect(UnsupportedOperationException.class); expectedException.expectMessage("Cannot adapt mutation of type"); expectedException.expectMessage("UnknownMutation"); adapter.adapt(unknownMutation, mutation); }