Frame createFrame( ByteBufAllocator byteBufAllocator, boolean complete, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { if (initialFragmentCreated) { return createPayloadFrame(byteBufAllocator, !complete, data == null, metadata, data); } else { initialFragmentCreated = true; return frame.createFragment(byteBufAllocator, metadata, data); } }
@DisplayName("creates fragment") @Test default void createFragment() { ByteBuf metadata = getRandomByteBuf(2); ByteBuf data = getRandomByteBuf(2); FragmentableFrame frame = getFrameWithoutFollowsFlagSet().createFragment(DEFAULT, metadata, data); assertThat(frame.isFollowsFlagSet()).isTrue(); assertThat(frame.mapMetadata(Function.identity())).hasValue(metadata); assertThat(frame.mapData(Function.identity())).isEqualTo(data); }
@DisplayName("createFragment throws NullPointerException with null ByteBufAllocator") @Test default void createInitialFragmentNullByteBufAllocator() { assertThatNullPointerException() .isThrownBy(() -> getFrameWithoutFollowsFlagSet().createFragment(null, null, null)) .withMessage("byteBufAllocator must not be null"); }
Frame createFrame( ByteBufAllocator byteBufAllocator, boolean complete, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { if (initialFragmentCreated) { return createPayloadFrame(byteBufAllocator, !complete, data == null, metadata, data); } else { initialFragmentCreated = true; return frame.createFragment(byteBufAllocator, metadata, data); } }