class ByteArrayAdapter extends TypeAdapter<byte[]> {

  @Override
  public byte[] deserialize(byte[] buffer, int bufferPosition) {
    int length = Serialization.readInt(buffer, bufferPosition);
    return Serialization.subArray(buffer, bufferPosition + SIZE_OF_INT, bufferPosition + SIZE_OF_INT + length);
  }

}

class ByteArrayAdapterTest {

  private final ByteArrayAdapter adapter;

  @Test
  public void testDecodeEmptyArray() {

    byte[] buffer = {0, 0, 0, 0};
    byte[] expected = {};
    assertArrayEquals(expected, adapter.deserialize(buffer, 0));
  }

}