SendEventRequestValidator { void validateInfo(Map<String, String> info, int maxInfoLength) { int infoLength = 0; for (Map.Entry<String, String> entry : info.entrySet()) { infoLength += entry.getKey().length(); infoLength += entry.getValue().length(); } if (infoLength > maxInfoLength) { throw new BadRequestException("info is too long, length=" + infoLength, "EVENT_TOO_LARGE"); } }    }
@Test void validateInfo() { assertThatThrownBy(() -> validator.validateInfo(Map.of("key", "value"), 7)) .isInstanceOf(BadRequestException.class) .hasMessageContaining("too long"); }