public void snapshotTimer(final long correlationId, final long deadline)
    {
        idleStrategy.reset();
        while (true)
        {
            final long result = publication.tryClaim(ENCODED_TIMER_LENGTH, bufferClaim);
            if (result > 0)
            {
                timerEncoder
                    .wrapAndApplyHeader(bufferClaim.buffer(), bufferClaim.offset(), messageHeaderEncoder)
                    .correlationId(correlationId)
                    .deadline(deadline);
                bufferClaim.commit();
                break;
            }

            checkResultAndIdle(result);
        }
    }
@Test
    void snapshotTimer()
    {
        final int offset = 18;
        final int length = MessageHeaderEncoder.ENCODED_LENGTH + TimerEncoder.BLOCK_LENGTH;
        final long correlationId = -901;
        final long deadline = 12345678901L;
        when(publication.tryClaim(eq(length), any()))
            .thenReturn(BACK_PRESSURED, ADMIN_ACTION)
            .thenAnswer(mockTryClaim(offset));

        snapshotTaker.snapshotTimer(correlationId, deadline);

        final InOrder inOrder = inOrder(idleStrategy, publication);
        inOrder.verify(idleStrategy).reset();
        inOrder.verify(publication).tryClaim(anyInt(), any());
        inOrder.verify(idleStrategy).idle();
        inOrder.verify(publication).tryClaim(anyInt(), any());
        inOrder.verify(idleStrategy).idle();
        inOrder.verify(publication).tryClaim(anyInt(), any());
        inOrder.verifyNoMoreInteractions();

        timerDecoder.wrapAndApplyHeader(buffer, offset + HEADER_LENGTH, messageHeaderDecoder);
        assertEquals(correlationId, timerDecoder.correlationId());
        assertEquals(deadline, timerDecoder.deadline());
    }