### Question:
SpanAdapter { static Span toProtoSpan(SpanData spanData) { final Span.Builder builder = Span.newBuilder(); builder.setTraceId(TraceProtoUtils.toProtoTraceId(spanData.getTraceId())); builder.setSpanId(TraceProtoUtils.toProtoSpanId(spanData.getSpanId())); if (SpanId.isValid(spanData.getParentSpanId())) { builder.setParentSpanId(TraceProtoUtils.toProtoSpanId(spanData.getParentSpanId())); } builder.setName(spanData.getName()); builder.setKind(toProtoSpanKind(spanData.getKind())); builder.setStartTimeUnixNano(spanData.getStartEpochNanos()); builder.setEndTimeUnixNano(spanData.getEndEpochNanos()); spanData .getAttributes() .forEach( new AttributeConsumer() { @Override public <T> void consume(AttributeKey<T> key, T value) { builder.addAttributes(CommonAdapter.toProtoAttribute(key, value)); } }); builder.setDroppedAttributesCount( spanData.getTotalAttributeCount() - spanData.getAttributes().size()); for (Event event : spanData.getEvents()) { builder.addEvents(toProtoSpanEvent(event)); } builder.setDroppedEventsCount(spanData.getTotalRecordedEvents() - spanData.getEvents().size()); for (SpanData.Link link : spanData.getLinks()) { builder.addLinks(toProtoSpanLink(link)); } builder.setDroppedLinksCount(spanData.getTotalRecordedLinks() - spanData.getLinks().size()); builder.setStatus(toStatusProto(spanData.getStatus())); return builder.build(); } private  SpanAdapter();   }### Answer:
@Test void toProtoSpan() { Span span = SpanAdapter.toProtoSpan( TestSpanData.newBuilder() .setHasEnded(true) .setTraceId(TRACE_ID) .setSpanId(SPAN_ID) .setParentSpanId(SpanId.getInvalid()) .setName("GET /api/endpoint") .setKind(Kind.SERVER) .setStartEpochNanos(12345) .setEndEpochNanos(12349) .setAttributes(Attributes.of(booleanKey("key"), true)) .setTotalAttributeCount(2) .setEvents( Collections.singletonList(Event.create(12347, "my_event", Attributes.empty()))) .setTotalRecordedEvents(3) .setLinks(Collections.singletonList(Link.create(SPAN_CONTEXT))) .setTotalRecordedLinks(2) .setStatus(SpanData.Status.ok()) .build()); assertThat(span.getTraceId().toByteArray()).isEqualTo(TRACE_ID_BYTES); assertThat(span.getSpanId().toByteArray()).isEqualTo(SPAN_ID_BYTES); assertThat(span.getParentSpanId().toByteArray()).isEqualTo(new byte[] {}); assertThat(span.getName()).isEqualTo("GET /api/endpoint"); assertThat(span.getKind()).isEqualTo(SPAN_KIND_SERVER); assertThat(span.getStartTimeUnixNano()).isEqualTo(12345); assertThat(span.getEndTimeUnixNano()).isEqualTo(12349); assertThat(span.getAttributesList()) .containsExactly( KeyValue.newBuilder() .setKey("key") .setValue(AnyValue.newBuilder().setBoolValue(true).build()) .build()); assertThat(span.getDroppedAttributesCount()).isEqualTo(1); assertThat(span.getEventsList()) .containsExactly( Span.Event.newBuilder().setTimeUnixNano(12347).setName("my_event").build()); assertThat(span.getDroppedEventsCount()).isEqualTo(2); assertThat(span.getLinksList()) .containsExactly( Span.Link.newBuilder() .setTraceId(ByteString.copyFrom(TRACE_ID_BYTES)) .setSpanId(ByteString.copyFrom(SPAN_ID_BYTES)) .build()); assertThat(span.getDroppedLinksCount()).isEqualTo(1); assertThat(span.getStatus()).isEqualTo(Status.newBuilder().setCode(STATUS_CODE_OK).build()); }