@SuppressWarnings("MethodLength")
    static void dissectCommand(
        final DriverEventCode code, final MutableDirectBuffer buffer, final int offset, final StringBuilder builder)
    {
        final int encodedLength = dissectLogHeader(CONTEXT, code, buffer, offset, builder);
        builder.append(": ");

        switch (code)
        {
            case CMD_IN_ADD_PUBLICATION:
            case CMD_IN_ADD_EXCLUSIVE_PUBLICATION:
                PUB_MSG.wrap(buffer, offset + encodedLength);
                dissectPublication(builder);
                break;

            case CMD_IN_ADD_SUBSCRIPTION:
                SUB_MSG.wrap(buffer, offset + encodedLength);
                dissectSubscription(builder);
                break;

            case CMD_IN_REMOVE_PUBLICATION:
            case CMD_IN_REMOVE_SUBSCRIPTION:
            case CMD_IN_REMOVE_COUNTER:
                REMOVE_MSG.wrap(buffer, offset + encodedLength);
                dissectRemoveEvent(builder);
                break;

            case CMD_OUT_PUBLICATION_READY:
            case CMD_OUT_EXCLUSIVE_PUBLICATION_READY:
                PUB_READY.wrap(buffer, offset + encodedLength);
                dissectPublicationReady(builder);
                break;

            case CMD_OUT_AVAILABLE_IMAGE:
                IMAGE_READY.wrap(buffer, offset + encodedLength);
                dissectImageReady(builder);
                break;

            case CMD_OUT_ON_OPERATION_SUCCESS:
                OPERATION_SUCCEEDED.wrap(buffer, offset + encodedLength);
                dissectOperationSuccess(builder);
                break;

            case CMD_IN_KEEPALIVE_CLIENT:
            case CMD_IN_CLIENT_CLOSE:
                CORRELATED_MSG.wrap(buffer, offset + encodedLength);
                dissectCorrelationEvent(builder);
                break;

            case CMD_OUT_ON_UNAVAILABLE_IMAGE:
                IMAGE_MSG.wrap(buffer, offset + encodedLength);
                dissectImage(builder);
                break;

            case CMD_IN_ADD_DESTINATION:
            case CMD_IN_REMOVE_DESTINATION:
            case CMD_IN_ADD_RCV_DESTINATION:
            case CMD_IN_REMOVE_RCV_DESTINATION:
                DESTINATION_MSG.wrap(buffer, offset + encodedLength);
                dissectDestination(builder);
                break;

            case CMD_OUT_ERROR:
                ERROR_MSG.wrap(buffer, offset + encodedLength);
                dissectError(builder);
                break;

            case CMD_IN_ADD_COUNTER:
                COUNTER_MSG.wrap(buffer, offset + encodedLength);
                dissectCounter(builder);
                break;

            case CMD_OUT_SUBSCRIPTION_READY:
                SUBSCRIPTION_READY.wrap(buffer, offset + encodedLength);
                dissectSubscriptionReady(builder);
                break;

            case CMD_OUT_COUNTER_READY:
            case CMD_OUT_ON_UNAVAILABLE_COUNTER:
                COUNTER_UPDATE.wrap(buffer, offset + encodedLength);
                dissectCounterUpdate(builder);
                break;

            case CMD_OUT_ON_CLIENT_TIMEOUT:
                CLIENT_TIMEOUT.wrap(buffer, offset + encodedLength);
                dissectClientTimeout(builder);
                break;

            case CMD_IN_TERMINATE_DRIVER:
                TERMINATE_DRIVER.wrap(buffer, offset + encodedLength);
                dissectTerminateDriver(builder);
                break;

            default:
                builder.append("COMMAND_UNKNOWN: ").append(code);
                break;
        }
    }
@Test
    void dissectCommandUnknown()
    {
        final DriverEventCode eventCode = SEND_CHANNEL_CREATION;
        internalEncodeLogHeader(buffer, 0, 5, 5, () -> 1_000_000_000L);

        dissectCommand(eventCode, buffer, 0, builder);

        assertEquals("[1.000000000] " + CONTEXT + ": " + eventCode.name() + " [5/5]: COMMAND_UNKNOWN: " + eventCode,
            builder.toString());
    }