'use strict';

const Queue = require('./../../model/queue/Queue');

/**
 * Manages the lifecycle of all queues in memory. Queues are not persisted in Azurite.
 * 
 * @class QueueManager
 */
class QueueManager {
    constructor() {
        this.queues = {};
    }

    add({ name, metaProps = {} }) {
        this.queues[name] = new Queue(metaProps);
    }

    delete(name) {
        delete this.queues[name];
    }

    getQueueAndMessage({ queueName = undefined, messageId = undefined }) {
        const queue = this.queues[queueName];
        let message = undefined;
        if (queue !== undefined && messageId !== undefined) {
            message = queue.getMessage(messageId);
        }
        return {
            queue: queue,
            message: message
        };
    }

    setQueueMetadata(request){
        const queue = this.getQueueAndMessage(request.queueName);
        
        //TODO: Implement setting Metadata for a specific Queue
    }
}

module.exports = new QueueManager();
@@ -886,72 +886,53 @@
     
-%0A        //TODO: Implement setting Metadata for a specific Queue
+queue.metaProps = request.metaProps;%0A        
 %0A   

implement setQueueMetadata