### Question:
ResourceAdapter { static Resource toProtoResource(io.opentelemetry.sdk.resources.Resource resource) { final Resource.Builder builder = Resource.newBuilder(); resource .getAttributes() .forEach( new AttributeConsumer() { @Override public <T> void consume(AttributeKey<T> key, T value) { builder.addAttributes(CommonAdapter.toProtoAttribute(key, value)); } }); return builder.build(); } private  ResourceAdapter();   }### Answer:
@Test void toProtoResource() { assertThat( ResourceAdapter.toProtoResource( Resource.create( Attributes.of( booleanKey("key_bool"), true, stringKey("key_string"), "string", longKey("key_int"), 100L, doubleKey("key_double"), 100.3))) .getAttributesList()) .containsExactlyInAnyOrder( KeyValue.newBuilder() .setKey("key_bool") .setValue(AnyValue.newBuilder().setBoolValue(true).build()) .build(), KeyValue.newBuilder() .setKey("key_string") .setValue(AnyValue.newBuilder().setStringValue("string").build()) .build(), KeyValue.newBuilder() .setKey("key_int") .setValue(AnyValue.newBuilder().setIntValue(100).build()) .build(), KeyValue.newBuilder() .setKey("key_double") .setValue(AnyValue.newBuilder().setDoubleValue(100.3).build()) .build()); }
@Test void toProtoResource_Empty() { assertThat(ResourceAdapter.toProtoResource(Resource.getEmpty())) .isEqualTo(io.opentelemetry.proto.resource.v1.Resource.newBuilder().build()); }