BeanBody implements Body { @Override public void send(Sender sender, ResponseHandlerContext context) { byte[] body = context.writer.toJSON(bean); LOGGER.debug("[response] body={}", new BytesLogParam(body)); sender.send(ByteBuffer.wrap(body)); } BeanBody(Object bean); @Override void send(Sender sender, ResponseHandlerContext context); final Object bean; }
@Test void send() { var writer = new ResponseBeanWriter(); writer.register(TestBean.class, new BeanClassValidator()); var context = new ResponseHandlerContext(writer, null); var body = new BeanBody(new TestBean()); assertThatThrownBy(() -> body.send(sender, context)) .isInstanceOf(ValidationException.class); }