// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_DEPENDENCY = 0;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_WEIGHT = 16;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_FRAME_HEADER_SIZE = 9;


import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_DEPENDENCY;
import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_WEIGHT;
import static com.twitter.http2.HttpCodecUtil.HTTP_FRAME_HEADER_SIZE;
import java.util.Random;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
        int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;
        boolean exclusive = RANDOM.nextBoolean();
        int dependency = RANDOM.nextInt() & 0x7FFFFFFF;
        int weight = RANDOM.nextInt() & 0xFF;

        ByteBuf frame = headersFrame(length, flags, streamId);
        writePriorityFields(frame, exclusive, dependency, weight);
        writeRandomData(frame, headerBlockLength);
        decoder.decode(frame);

        InOrder inOrder = inOrder(delegate);
        inOrder.verify(delegate).readHeadersFrame(
                streamId, false, false, exclusive, dependency, weight + 1);
        inOrder.verify(delegate).readHeaderBlock(
                frame.slice(HTTP_FRAME_HEADER_SIZE + 5, headerBlockLength));
        inOrder.verify(delegate).readHeaderBlockEnd();
        verifyNoMoreInteractions(delegate);
    }

    @Test
    public void testLastHttpHeadersFrame() throws Exception {
        int length = 0;
        byte flags = 0x01 | 0x04; // END_STREAM | END_HEADERS
        int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

        ByteBuf frame = headersFrame(length, flags, streamId);
        decoder.decode(frame);

        InOrder inOrder = inOrder(delegate);
        inOrder.verify(delegate).readHeadersFrame(
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_DEPENDENCY = 0;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_WEIGHT = 16;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_FRAME_HEADER_SIZE = 9;


// Path: src/test/java/com/twitter/http2/HttpFrameDecoderTest.java
import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_DEPENDENCY;
import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_WEIGHT;
import static com.twitter.http2.HttpCodecUtil.HTTP_FRAME_HEADER_SIZE;
import java.util.Random;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;

        int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;
        boolean exclusive = RANDOM.nextBoolean();
        int dependency = RANDOM.nextInt() & 0x7FFFFFFF;
        int weight = RANDOM.nextInt() & 0xFF;

        ByteBuf frame = headersFrame(length, flags, streamId);
        writePriorityFields(frame, exclusive, dependency, weight);
        writeRandomData(frame, headerBlockLength);
        decoder.decode(frame);

        InOrder inOrder = inOrder(delegate);
        inOrder.verify(delegate).readHeadersFrame(
                streamId, false, false, exclusive, dependency, weight + 1);
        inOrder.verify(delegate).readHeaderBlock(
                frame.slice(HTTP_FRAME_HEADER_SIZE + 5, headerBlockLength));
        inOrder.verify(delegate).readHeaderBlockEnd();
        verifyNoMoreInteractions(delegate);
    }

    @Test
    public void testLastHttpHeadersFrame() throws Exception {
        int length = 0;
        byte flags = 0x01 | 0x04; // END_STREAM | END_HEADERS
        int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

        ByteBuf frame = headersFrame(length, flags, streamId);
        decoder.decode(frame);

        InOrder inOrder = inOrder(delegate);
        inOrder.verify(delegate).readHeadersFrame(
                streamId, true, false, false, HTTP_DEFAULT_DEPENDENCY, HTTP_DEFAULT_WEIGHT);