### Question:
AbstractBodyAdapter implements BodyAdapter { public static BodyPublisher attachMediaType( BodyPublisher publisher, @Nullable MediaType mediaType) { requireNonNull(publisher); if (mediaType != null && !mediaType.hasWildcard()) { return MoreBodyPublishers.ofMediaType(publisher, mediaType); } return publisher; } protected  AbstractBodyAdapter(MediaType... compatibleMediaTypes); @Override final boolean isCompatibleWith(MediaType mediaType); static Charset charsetOrDefault(@Nullable MediaType mediaType, Charset defaultCharset); static Charset charsetOrUtf8(@Nullable MediaType mediaType); static BodyPublisher attachMediaType(
      BodyPublisher publisher, @Nullable MediaType mediaType);  }### Answer:
@Test void attachMediaType() { var textPlain = MediaType.of("text", "plain"); var source = BodyPublishers.ofString("hello there"); var withMediaType = AbstractBodyAdapter.attachMediaType(source, textPlain); var withoutMediaType = AbstractBodyAdapter.attachMediaType(source, null); var withoutMediaType2 = AbstractBodyAdapter.attachMediaType( source, MediaType.of("text", "*")); assertTrue(withMediaType instanceof MimeBodyPublisher); assertEquals(textPlain, ((MimeBodyPublisher) withMediaType).mediaType()); assertSame(source, withoutMediaType); assertSame(source, withoutMediaType2); }