MoshiSpanDecoder { public List<Span> decodeList(byte[] spans) { BufferedSource source = new Buffer().write(spans); try { return listSpansAdapter.fromJson(source); } catch (IOException e) { throw new AssertionError(e); } } MoshiSpanDecoder(); static MoshiSpanDecoder create(); List<Span> decodeList(byte[] spans); List<Span> decodeList(ByteBuffer spans); static final JsonAdapter<Span> SPAN_ADAPTER; }
@Test public void decodeList_bytes() { assertThat(new MoshiSpanDecoder().decodeList(encoded)) .isEqualTo(TRACE); }
@Test public void decodeList_byteBuffer() { ByteBuf encodedBuf = PooledByteBufAllocator.DEFAULT.buffer(encoded.length); encodedBuf.writeBytes(encoded); try { assertThat(new MoshiSpanDecoder().decodeList(encodedBuf.nioBuffer())) .isEqualTo(TRACE); } finally { encodedBuf.release(); } }