public <E extends Enum<E>> void logUntetheredSubscriptionStateChange(
        final E oldState, final E newState, final long subscriptionId, final int streamId, final int sessionId)
    {
        final int length = untetheredSubscriptionStateChangeLength(oldState, newState);
        final int captureLength = captureLength(length);
        final int encodedLength = encodedLength(captureLength);
        final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
        final int index = ringBuffer.tryClaim(toEventCodeId(UNTETHERED_SUBSCRIPTION_STATE_CHANGE), encodedLength);

        if (index > 0)
        {
            try
            {
                encodeUntetheredSubscriptionStateChange(
                    (UnsafeBuffer)ringBuffer.buffer(),
                    index,
                    captureLength,
                    length,
                    oldState,
                    newState,
                    subscriptionId,
                    streamId,
                    sessionId);
            }
            finally
            {
                ringBuffer.commit(index);
            }
        }
    }
@Test
    void logUntetheredSubscriptionStateChange()
    {
        final int recordOffset = align(192, ALIGNMENT);
        logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, recordOffset);
        final TimeUnit from = TimeUnit.DAYS;
        final TimeUnit to = TimeUnit.NANOSECONDS;
        final long subscriptionId = Long.MIN_VALUE;
        final int streamId = 61;
        final int sessionId = 8;
        final int captureLength = captureLength(untetheredSubscriptionStateChangeLength(from, to));

        logger.logUntetheredSubscriptionStateChange(from, to, subscriptionId, streamId, sessionId);

        verifyLogHeader(
            logBuffer, recordOffset, toEventCodeId(UNTETHERED_SUBSCRIPTION_STATE_CHANGE), captureLength, captureLength);
        assertEquals(subscriptionId,
            logBuffer.getLong(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH), LITTLE_ENDIAN));
        assertEquals(streamId,
            logBuffer.getInt(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + SIZE_OF_LONG), LITTLE_ENDIAN));
        assertEquals(sessionId,
            logBuffer.getInt(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + SIZE_OF_LONG + SIZE_OF_INT),
            LITTLE_ENDIAN));
        assertEquals(from.name() + STATE_SEPARATOR + to.name(), logBuffer.getStringAscii(
            encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + SIZE_OF_INT * 2 + SIZE_OF_LONG), LITTLE_ENDIAN));
    }