### Question:
MantisEventAggregator extends ChannelOutboundHandlerAdapter { FullHttpRequest buildRequest(ChannelHandlerContext ctx, MantisEventEnvelope event) throws IOException { InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); String urlString = "http: URI uri = URI.create(urlString); FullHttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.POST, uri.getRawPath(), ctx.alloc().directBuffer()); request.headers().add(HttpHeaderNames.ACCEPT, HttpHeaderValues.APPLICATION_JSON); request.headers().add(HttpHeaderNames.ORIGIN, "localhost"); if (compress) { request.headers().add(HttpHeaderNames.CONTENT_ENCODING, HttpHeaderValues.GZIP); } request.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); event.setTs(clock.millis()); try (OutputStream bbos = new ByteBufOutputStream(request.content())) { objectWriter.writeValue(bbos, event); } return request; } MantisEventAggregator(Registry registry,
                          Clock clock,
                          boolean compress,
                          long flushIntervalMs,
                          int flushIntervalBytes); @Override void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(ChannelHandlerContext ctx);  }### Answer:
@Test void shouldBuildValidHeaders() throws IOException { MantisEventEnvelope envelope = new MantisEventEnvelope(clock.millis(), "origin", new ArrayList<>()); envelope.addEvent(new MantisEvent(1, "v")); FullHttpRequest request = aggregator.buildRequest(ctx, envelope); HttpHeaders expectedHeaders = new DefaultHttpHeaders(); expectedHeaders.add(HttpHeaderNames.ACCEPT, HttpHeaderValues.APPLICATION_JSON); expectedHeaders.add(HttpHeaderNames.ORIGIN, "localhost"); request.headers().set(HttpHeaderNames.CONTENT_ENCODING, HttpHeaderValues.GZIP); expectedHeaders.add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); for (int i = 0; i < expectedHeaders.entries().size(); i++) { assertEquals( expectedHeaders.entries().get(i).getKey(), request.headers().entries().get(i).getKey()); assertEquals( expectedHeaders.entries().get(i).getValue(), request.headers().entries().get(i).getValue()); } }