@Test public void testGetRowKey() { ImmutableBytesWritable rowKey = hbMapper.getRowKey( new HBRecord() { @Override public String composeRowKey() { return "rowkey"; } @Override public void parseRowKey(String rowKey) {} }); assertEquals("Row keys don't match", rowKey, Util.strToIbw("rowkey")); try { hbMapper.getRowKey( new HBRecord() { @Override public String composeRowKey() { return null; } @Override public void parseRowKey(String rowKey) {} }); fail("null row key should've thrown a " + RowKeyCantBeEmptyException.class.getName()); } catch (RowKeyCantBeEmptyException ignored) { } try { hbMapper.getRowKey( new HBRecord() { @Override public String composeRowKey() { throw new RuntimeException("Some blah"); } @Override public void parseRowKey(String rowKey) {} }); fail( "If row key can't be composed, an " + RowKeyCantBeComposedException.class.getName() + " was expected"); } catch (RowKeyCantBeComposedException ignored) { } try { hbMapper.getRowKey(null); fail("If object is null, a " + NullPointerException.class.getName() + " was expected"); } catch (NullPointerException ignored) { } }