JacksonCborFactory implements CborFactory { @Override public void writeToByteBuffer(final JsonValue jsonValue, final ByteBuffer byteBuffer) throws IOException { final ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(byteBuffer); writeToOutputStream(jsonValue, byteBufferOutputStream); } JacksonCborFactory(); @Override boolean isCborAvailable(); @Override JsonValue readFrom(final byte[] bytes); @Override JsonValue readFrom(final byte[] bytes, final int offset, final int length); @Override JsonValue readFrom(final ByteBuffer byteBuffer); @Override byte[] toByteArray(final JsonValue jsonValue); @Override ByteBuffer toByteBuffer(final JsonValue jsonValue); @Override void writeToByteBuffer(final JsonValue jsonValue, final ByteBuffer byteBuffer); @Override byte[] createCborRepresentation(final Map<String, JsonField> jsonFieldMap, final int guessedSerializedSize); @Override byte[] createCborRepresentation(final List<JsonValue> list, final int guessedSerializedSize);  }
@Test public void writeToByteBufferWorks() throws IOException { final ByteBuffer allocate = ByteBuffer.allocate(512); cborFactory.writeToByteBuffer(testValue, allocate); allocate.flip(); assertThat(BinaryToHexConverter.toHexString(allocate)).isEqualTo(CborTestUtils.serializeToHexString(testValue)); }