BodyLogParam { public static Object of(byte[] body, ContentType contentType) { if (contentType != null && (APPLICATION_JSON.mediaType.equals(contentType.mediaType) || contentType.mediaType.contains("text") || contentType.mediaType.contains("xml"))) { return new BytesLogParam(body, contentType.charset().orElse(UTF_8)); } return "byte[" + body.length + "]"; }  static Object of(byte[] body, ContentType contentType);  }
@Test void bodyParam() { assertThat(BodyLogParam.of(Strings.bytes("{}"), ContentType.APPLICATION_JSON)) .isInstanceOf(BytesLogParam.class); assertThat(BodyLogParam.of(Strings.bytes("<xml/>"), ContentType.TEXT_XML)) .isInstanceOf(BytesLogParam.class); assertThat(BodyLogParam.of(Strings.bytes("value"), null)) .isEqualTo("byte[5]"); assertThat(BodyLogParam.of(new byte[10], ContentType.IMAGE_PNG)) .isEqualTo("byte[10]"); }