### Question:
Message { public <V> Result<V, Failure> body(final Format<V> format) { if ( format == null ) { throw new NullPointerException("null body"); } final V cached=(V)bodies.get(format); return cached != null ? Value(cached) : format.get(self()).value(value -> { bodies.put(format, value); return value; }); }  abstract String item(); abstract Request request(); R map(final Function<T, R> mapper); T lift(final Message<?> message); Message<?> link(final String item); boolean interactive(); Optional<String> charset(); Shape shape(); T shape(final Shape shape); Map<String, Collection<String>> headers(); T headers(final Map<String, ? extends Collection<String>> headers); Optional<String> header(final String name); T header(final String name, final String value); Collection<String> headers(final String name); T headers(final String name, final String... values); T headers(final String name, final Collection<String> values); Result<V, Failure> body(final Format<V> format); T body(final Format<V> format, final V value);  }### Answer:
@Test void testBodyCaching() { final MessageMock message=new MessageMock().body(reader(), () -> new StringReader("test")); final Function<Message<?>, String> accessor=m -> m .body(text()).fold(value -> value, error -> fail("missing test body")); assertSame(accessor.apply(message), accessor.apply(message)); }