### Question:
QueueConfig extends AbstractConfig { public Queue buildQueue(QueueConfig defaultQueueConfig, DeadLetterConfig deadLetterConfig) { if (!isDefaultConfigApplied()) { applyDefaultConfig(defaultQueueConfig); } Queue queue = new Queue(getName(), getDurable(), getExclusive(), getAutoDelete(), getArguments()); if (Boolean.TRUE.equals(getDeadLetterEnabled())) { if (deadLetterConfig == null || deadLetterConfig.getDeadLetterExchange() == null) { throw new RabbitmqConfigurationException( String.format("Invalid configuration %s : DeadLetterConfig/DeadLetterExchange must be provided when deadLetterEnabled=true for queue %s.", getName(), getName())); } queue.getArguments().put("x-dead-letter-exchange", deadLetterConfig.getDeadLetterExchange().getName()); queue.getArguments().put("x-dead-letter-routing-key", deadLetterConfig.createDeadLetterQueueName(getName())); } return queue; }  boolean validate(); QueueConfig applyDefaultConfig(QueueConfig defaultQueueConfig); Queue buildQueue(QueueConfig defaultQueueConfig, DeadLetterConfig deadLetterConfig); Queue buildDeadLetterQueue(QueueConfig defaultQueueConfig, DeadLetterConfig deadLetterConfig);  }### Answer:
@Test public void createQueueWithNoDeadLetterAndDefaultConfigurationAppliedTest() { defaultQueueConfig = QueueConfig.builder().build(); queueConfig = QueueConfig.builder().name(queueName).build(); expectedQueueConfig = QueueConfig.builder() .name(queueName).durable(false).autoDelete(false).exclusive(false).deadLetterEnabled(false).arguments(new HashMap<>()) .build(); Queue queue = queueConfig.buildQueue(defaultQueueConfig, null); assertQueue(queue, expectedQueueConfig); }
@Test(expected = RabbitmqConfigurationException.class) public void createQueueWithDeadLetterAndNoDeadLetterConfig() { defaultQueueConfig = QueueConfig.builder().deadLetterEnabled(true).build(); queueConfig = QueueConfig.builder().name(queueName).build(); Queue queue = queueConfig.buildQueue(defaultQueueConfig, null); assertQueue(queue, expectedQueueConfig); }
@Test public void createQueueWithNoDeadLetterAndNoDeadLetterConfig() { defaultQueueConfig = QueueConfig.builder().deadLetterEnabled(false).build(); queueConfig = QueueConfig.builder().name(queueName).build(); expectedQueueConfig = QueueConfig.builder() .name(queueName).durable(false).autoDelete(false).exclusive(false).deadLetterEnabled(false) .build(); Queue queue = queueConfig.buildQueue(defaultQueueConfig, null); assertQueue(queue, expectedQueueConfig); }