### Question:
MoreBodyPublishers { public static BodyPublisher ofObject(Object object, @Nullable MediaType mediaType) { TypeRef<?> runtimeType = TypeRef.from(object.getClass()); Encoder encoder = Encoder.getEncoder(runtimeType, mediaType) .orElseThrow(() -> unsupportedConversion(runtimeType, mediaType)); return encoder.toBody(object, mediaType); } private  MoreBodyPublishers(); static MimeBodyPublisher ofMediaType(BodyPublisher bodyPublisher, MediaType mediaType); static BodyPublisher ofObject(Object object, @Nullable MediaType mediaType);  }### Answer:
@Test void ofObject_charBufferBody() { var content = CharBuffer.wrap("<p>very important text</p>"); var body = ofObject(content, MediaType.parse("text/html")); assertEquals(content, US_ASCII.decode(BodyCollector.collect(body))); }
@Test void ofObject_unsupported() { assertThrows(UnsupportedOperationException.class, () -> ofObject(5555, null)); assertThrows(UnsupportedOperationException.class, () -> ofObject("blah", MediaType.parse("application/json"))); }