@Test
public void testGetBytes() {

    final List<byte[]> captures = new ArrayList<>();
    new Expectations(hash) {
        {
            hash.length();
            result = 5;
            hash.writeBytes(withCapture(captures), 0, 5);
        }
    };
    hash.getBytes();
    assertEquals(5, captures.get(0).length);
}