### Question:
ExchangeRegistry { void declareExchange(String exchangeName, String type, boolean passive, boolean durable) throws ValidationException, BrokerException { if (exchangeName.isEmpty()) { throw new ValidationException("Exchange name cannot be empty."); } Exchange exchange = exchangeMap.get(exchangeName); if (passive) { if (Objects.isNull(exchange)) { throw new ValidationException("Exchange [ " + exchangeName + " ] doesn't exists. Passive parameter " + "is set, hence not creating the exchange."); } } else { createExchange(exchangeName, Exchange.Type.from(type), durable); } } ExchangeRegistry(ExchangeDao exchangeDao, BindingDao bindingDao); void createExchange(String exchangeName, Exchange.Type type, boolean durable); Exchange getDefaultExchange(); void retrieveFromStore(QueueRegistry queueRegistry); Collection<Exchange> getAllExchanges(); static final String DEFAULT_DEAD_LETTER_EXCHANGE; }### Answer:
@Test(description = "Test frequently used exchanges types are defined", expectedExceptions = ValidationException.class) public void testDeclareExchangesWithEmptyName() throws ValidationException, BrokerException { exchangeRegistry.declareExchange("", DIRECT.toString(), false, true); }
@Test(dataProvider = "exchangeNames", description = "declare a existing exchange with passive parameter set") public void testDeclareExistingExchangesWithPassiveParameter(String exchangeName) throws BrokerException, ValidationException { exchangeRegistry.declareExchange(exchangeName, null, true, true); exchangeRegistry.declareExchange(exchangeName, "", true, false); exchangeRegistry.declareExchange(exchangeName, DIRECT.toString(), true, true); }
@Test(description = "Declare a non-existing exchange with passive parameter set", expectedExceptions = ValidationException.class) public void testDeclareNonExistingExchangesWithPassiveParameter() throws BrokerException, ValidationException { exchangeRegistry.declareExchange(NON_EXISTING_EXCHANGE, DIRECT.toString(), true, false); Assert.fail("Declaring a non existing exchange with passive parameter set should throw a error."); }