### Question:
QueueConfig extends AbstractConfig { public QueueConfig applyDefaultConfig(QueueConfig defaultQueueConfig) { log.debug("Applying DefaultQueueConfig on the current QueueConfig :: QueueConfig = {{}} , DefaultQueueConfig = {{}}", this, defaultQueueConfig); setDurable(getDefaultConfig(getName(), "durable", getDurable(), defaultQueueConfig.getDurable(), Boolean.FALSE)); setAutoDelete(getDefaultConfig(getName(), "autoDelete", getAutoDelete(), defaultQueueConfig.getAutoDelete(), Boolean.FALSE)); setExclusive(getDefaultConfig(getName(), "exclusive", getExclusive(), defaultQueueConfig.getExclusive(), Boolean.FALSE)); setDeadLetterEnabled(getDefaultConfig(getName(), "deadLetterEnabled", getDeadLetterEnabled(), defaultQueueConfig.getDeadLetterEnabled(), Boolean.FALSE)); setArguments(loadArguments(getArguments(), defaultQueueConfig.getArguments())); setDefaultConfigApplied(true); log.info("DefaultQueueConfig applied on the current ExchangeConfig :: ExchangeConfig = {{}} , DefaultQueueConfig = {{}}", this, defaultQueueConfig); return this; }  boolean validate(); QueueConfig applyDefaultConfig(QueueConfig defaultQueueConfig); Queue buildQueue(QueueConfig defaultQueueConfig, DeadLetterConfig deadLetterConfig); Queue buildDeadLetterQueue(QueueConfig defaultQueueConfig, DeadLetterConfig deadLetterConfig);  }### Answer:
@Test public void defaultQueueConfigWithDefaultConfigurationAppliedTest() { queueConfig = QueueConfig.builder().build().applyDefaultConfig(defaultQueueConfig); expectedQueueConfig = QueueConfig.builder().durable(false).autoDelete(false).exclusive(false).deadLetterEnabled(false).build(); assertNull(queueConfig.getName()); assertFalse(queueConfig.getDurable()); assertFalse(queueConfig.getAutoDelete()); assertFalse(queueConfig.getExclusive()); assertFalse(queueConfig.getDeadLetterEnabled()); assertNotNull(queueConfig.getArguments()); assertTrue(queueConfig.isDefaultConfigApplied()); assertTrue(CollectionUtils.isEmpty(queueConfig.getArguments())); assertThat(queueConfig, equalTo(expectedQueueConfig)); }
@Test public void queueConfigWithOnlyQueueNameAndDefaultConfigurationAppliedTest() { queueConfig = QueueConfig.builder().name(queueName).build().applyDefaultConfig(defaultQueueConfig); expectedQueueConfig = QueueConfig.builder().name(queueName).durable(false).autoDelete(false).exclusive(false).deadLetterEnabled(false).build(); assertThat(queueConfig, equalTo(expectedQueueConfig)); }
@Test public void queueConfigWithOnlyQueueNameAndFewDefaultConfigurationTest() { defaultQueueConfig = QueueConfig.builder() .durable(true).autoDelete(true).exclusive(true).deadLetterEnabled(true).argument("key1", "value1") .build(); queueConfig = QueueConfig.builder().name(queueName).build().applyDefaultConfig(defaultQueueConfig); expectedQueueConfig = QueueConfig.builder() .name(queueName).durable(true).autoDelete(true).exclusive(true).deadLetterEnabled(true) .argument("key1", "value1") .build(); assertThat(queueConfig, equalTo(expectedQueueConfig)); }
@Test public void queueConfigByOverridingFromDefaultConfigurationTest() { defaultQueueConfig = QueueConfig.builder() .durable(true).autoDelete(true).exclusive(true).deadLetterEnabled(true).argument("key1", "value1") .build(); queueConfig = QueueConfig.builder() .name(queueName).durable(false).autoDelete(false) .argument("key1", "NEW_VALUE").argument("key2", "value2") .build() .applyDefaultConfig(defaultQueueConfig); expectedQueueConfig = QueueConfig.builder() .name(queueName).durable(false).autoDelete(false).exclusive(true).deadLetterEnabled(true) .argument("key1", "NEW_VALUE").argument("key2", "value2") .build(); assertThat(queueConfig, equalTo(expectedQueueConfig)); }