### Question:
DefaultFlowControlHandler implements FlowControlHandler { public void onReceivePacket(final Packet packet, final PipelineContext ctx) { if (packet instanceof FullPacket) { final FullPacket fp = (FullPacket) packet; for (final Frame frame : fp.getPayload().getFrames()) { if (frame.getType() == FrameType.MAX_STREAM_DATA) { final MaxStreamDataFrame msd = (MaxStreamDataFrame) frame; sendCounter.setStreamMaxBytes(msd.getStreamId(), msd.getMaxStreamData()); blockedStreams.remove(msd.getStreamId()); } else if (frame.getType() == FrameType.MAX_DATA) { final MaxDataFrame mdf = (MaxDataFrame) frame; sendCounter.setConnectionMaxBytes(mdf.getMaxData()); connectionBlocked.set(false); } else if (frame.getType() == FrameType.STREAM) { final StreamFrame sf = (StreamFrame) frame; final long sid = sf.getStreamId(); final TryConsumeResult result = receiveCounter.tryConsume(sid, sf.getOffset() + sf.getData().length); if (result.isSuccess()) { final List<Frame> frames = new ArrayList<>(); if (1.0 * result.getConnectionOffset() / result.getConnectionMax() > 0.5) { final long newMax = receiveCounter.increaseConnectionMax(); frames.add(new MaxDataFrame(newMax)); } if (1.0 * result.getStreamOffset() / result.getStreamMax() > 0.5) { final long newMax = receiveCounter.increaseStreamMax(sid); frames.add(new MaxStreamDataFrame(sid, newMax)); } if (!frames.isEmpty()) { ctx.send(frames.toArray(new Frame[0])); } } else { ctx.closeConnection( TransportError.FLOW_CONTROL_ERROR, FrameType.STREAM, "Flow control error"); } } } } ctx.next(packet); } DefaultFlowControlHandler(final long connectionMaxBytes, final long streamMaxBytes); @Override void beforeSendPacket(final Packet packet, final PipelineContext ctx); void onReceivePacket(final Packet packet, final PipelineContext ctx);  }### Answer:
@Test public void streamFrames() { Packet packet = p(new StreamFrame(sid, 0, false, new byte[3])); handler.onReceivePacket(packet, ctx); verify(ctx).next(packet); packet = p(new StreamFrame(sid, 3, false, new byte[3])); handler.onReceivePacket(packet, ctx); verify(ctx).send(new MaxStreamDataFrame(sid, 20)); verify(ctx).next(packet); packet = p(new StreamFrame(sid, 6, false, new byte[3])); handler.onReceivePacket(packet, ctx); verify(ctx).send(new MaxDataFrame(30)); verify(ctx).next(packet); packet = p(new StreamFrame(sid, 10, false, new byte[11])); handler.onReceivePacket(packet, ctx); verify(ctx) .closeConnection(eq(TransportError.FLOW_CONTROL_ERROR), eq(FrameType.STREAM), anyString()); verify(ctx).next(packet); }