public void onFragment(final DirectBuffer buffer, final int offset, final int length, final Header header)
    {
        final byte flags = header.flags();

        if ((flags & UNFRAGMENTED) == UNFRAGMENTED)
        {
            delegate.onFragment(buffer, offset, length, header);
        }
        else
        {
            handleFragment(buffer, offset, length, header, flags);
        }
    }
@Test
    void shouldSkipOverMessagesWithLoss()
    {
        when(header.flags())
            .thenReturn(FrameDescriptor.BEGIN_FRAG_FLAG)
            .thenReturn(FrameDescriptor.END_FRAG_FLAG)
            .thenReturn(FrameDescriptor.UNFRAGMENTED);

        final UnsafeBuffer srcBuffer = new UnsafeBuffer(new byte[2048]);
        final int length = 256;

        int offset = HEADER_LENGTH;
        assembler.onFragment(srcBuffer, offset, length, header);
        offset = BitUtil.align(offset + length + HEADER_LENGTH, FRAME_ALIGNMENT);
        offset = BitUtil.align(offset + length + HEADER_LENGTH, FRAME_ALIGNMENT);
        offset = BitUtil.align(offset + length + HEADER_LENGTH, FRAME_ALIGNMENT);
        assembler.onFragment(srcBuffer, offset, length, header);
        offset = BitUtil.align(offset + length + HEADER_LENGTH, FRAME_ALIGNMENT);
        assembler.onFragment(srcBuffer, offset, length, header);

        final ArgumentCaptor<Header> headerArg = ArgumentCaptor.forClass(Header.class);

        verify(delegateFragmentHandler, times(1)).onFragment(
            any(), eq(offset), eq(length), headerArg.capture());

        final Header capturedHeader = headerArg.getValue();
        assertEquals(SESSION_ID, capturedHeader.sessionId());
        assertEquals(FrameDescriptor.UNFRAGMENTED, capturedHeader.flags());
    }