TextUtil { public static ByteBuffer getByteBuffer(final Text text) { if (text == null) { return null; } byte[] bytes = text.getBytes(); return ByteBuffer.wrap(bytes, 0, text.getLength()); } private  TextUtil(); static byte[] getBytes(final Text text); static ByteBuffer getByteBuffer(final Text text);  }
@Test public void testGetByteBufferReturnsNullWhenTextIsNull() { assertEquals(null, TextUtil.getByteBuffer(null)); }
@Test public void testGetByteBuffer() { final Text text = new Text("Some text"); assertEquals(ByteBuffer.wrap(text.getBytes()), TextUtil.getByteBuffer(text)); }