### Question:
StructuredEventFilterUtil { public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; }  InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset); void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime,
            String responseBody);  }### Answer:
@Test public void testLogInboundEntityWhenMarkSupportedAndContentLongerThenMax() throws IOException { int length = LoggingStream.MAX_CONTENT_LENGTH * 2; String generatedString = RandomStringUtils.random(length, true, true); ByteArrayInputStream bais = new ByteArrayInputStream(generatedString.getBytes()); StringBuilder sb = new StringBuilder(); InputStream actual = underTest.logInboundEntity(sb, bais, Charset.defaultCharset()); Assertions.assertEquals(bais, actual); Assertions.assertTrue(sb.toString().endsWith("...more...\n")); }
@Test public void testLogInboundEntityWhenMarkNotSupportedAndContentLongerThenMax() throws IOException { int length = LoggingStream.MAX_CONTENT_LENGTH * 2; String generatedString = RandomStringUtils.random(length, true, true); ByteArrayInputStream bais = new ByteArrayInputStream(generatedString.getBytes()); DataInputStream inputStream = new DataInputStream(bais) { @Override public boolean markSupported() { return false; } }; StringBuilder sb = new StringBuilder(); InputStream actual = underTest.logInboundEntity(sb, inputStream, Charset.defaultCharset()); Assertions.assertNotEquals(inputStream, actual); Assertions.assertTrue(sb.toString().endsWith("...more...\n")); }
@Test public void testLogInboundEntityWhenMarkSupportedAndContentLessThenMax() throws IOException { int length = 20; String generatedString = RandomStringUtils.random(length, true, true); ByteArrayInputStream bais = new ByteArrayInputStream(generatedString.getBytes()); StringBuilder sb = new StringBuilder(); InputStream actual = underTest.logInboundEntity(sb, bais, Charset.defaultCharset()); Assertions.assertEquals(bais, actual); Assertions.assertFalse(sb.toString().endsWith("...more...\n")); Assertions.assertEquals(sb.length(), 21); }