### Question:
ThriftHBaseServiceHandler implements THBaseService.Iface { @Override public boolean checkAndDelete(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TDelete deleteSingle) throws TIOError, TException { HTableInterface htable = getTable(table.array()); try { if (value == null) { return htable.checkAndDelete(row.array(), family.array(), qualifier.array(), null, deleteFromThrift(deleteSingle)); } else { return htable.checkAndDelete(row.array(), family.array(), qualifier.array(), value.array(), deleteFromThrift(deleteSingle)); } } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } } ThriftHBaseServiceHandler(Configuration conf); static THBaseService.Iface newInstance(
      Configuration conf, ThriftMetrics metrics); @Override boolean exists(ByteBuffer table, TGet get); @Override TResult get(ByteBuffer table, TGet get); @Override List<TResult> getMultiple(ByteBuffer table, List<TGet> gets); @Override void put(ByteBuffer table, TPut put); @Override boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put); @Override void putMultiple(ByteBuffer table, List<TPut> puts); @Override void deleteSingle(ByteBuffer table, TDelete deleteSingle); @Override List<TDelete> deleteMultiple(ByteBuffer table, List<TDelete> deletes); @Override boolean checkAndDelete(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value,
      TDelete deleteSingle); @Override TResult increment(ByteBuffer table, TIncrement increment); @Override int openScanner(ByteBuffer table, TScan scan); @Override List<TResult> getScannerRows(int scannerId, int numRows); @Override void closeScanner(int scannerId);  }### Answer:
@Test public void testCheckAndDelete() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = "testCheckAndDelete".getBytes(); ByteBuffer table = ByteBuffer.wrap(tableAname); List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>(); TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname)); columnValuesA.add(columnValueA); TPut putA = new TPut(ByteBuffer.wrap(rowName), columnValuesA); putA.setColumnValues(columnValuesA); List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>(); TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname), ByteBuffer.wrap(valueBname)); columnValuesB.add(columnValueB); TPut putB = new TPut(ByteBuffer.wrap(rowName), columnValuesB); putB.setColumnValues(columnValuesB); handler.put(table, putB); TDelete delete = new TDelete(ByteBuffer.wrap(rowName)); assertFalse(handler.checkAndDelete(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), delete)); TGet get = new TGet(ByteBuffer.wrap(rowName)); TResult result = handler.get(table, get); assertArrayEquals(rowName, result.getRow()); assertTColumnValuesEqual(columnValuesB, result.getColumnValues()); handler.put(table, putA); assertTrue(handler.checkAndDelete(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), delete)); result = handler.get(table, get); assertFalse(result.isSetRow()); assertEquals(0, result.getColumnValuesSize()); }