### Question:
SpanAdapter { static Span.Link toProtoSpanLink(SpanData.Link link) { final Span.Link.Builder builder = Span.Link.newBuilder(); builder.setTraceId(TraceProtoUtils.toProtoTraceId(link.getContext().getTraceIdAsHexString())); builder.setSpanId(TraceProtoUtils.toProtoSpanId(link.getContext().getSpanIdAsHexString())); Attributes attributes = link.getAttributes(); attributes.forEach( new AttributeConsumer() { @Override public <T> void consume(AttributeKey<T> key, T value) { builder.addAttributes(CommonAdapter.toProtoAttribute(key, value)); } }); builder.setDroppedAttributesCount(link.getTotalAttributeCount() - attributes.size()); return builder.build(); } private  SpanAdapter();   }### Answer:
@Test void toProtoSpanLink_WithoutAttributes() { assertThat(SpanAdapter.toProtoSpanLink(Link.create(SPAN_CONTEXT))) .isEqualTo( Span.Link.newBuilder() .setTraceId(ByteString.copyFrom(TRACE_ID_BYTES)) .setSpanId(ByteString.copyFrom(SPAN_ID_BYTES)) .build()); }
@Test void toProtoSpanLink_WithAttributes() { assertThat( SpanAdapter.toProtoSpanLink( Link.create(SPAN_CONTEXT, Attributes.of(stringKey("key_string"), "string"), 5))) .isEqualTo( Span.Link.newBuilder() .setTraceId(ByteString.copyFrom(TRACE_ID_BYTES)) .setSpanId(ByteString.copyFrom(SPAN_ID_BYTES)) .addAttributes( KeyValue.newBuilder() .setKey("key_string") .setValue(AnyValue.newBuilder().setStringValue("string").build()) .build()) .setDroppedAttributesCount(4) .build()); }