### Question:
ExchangeDaoImpl extends BaseDao implements ExchangeDao { @Override public void persist(Exchange exchange) throws BrokerException { Connection connection = null; PreparedStatement statement = null; try { connection = getConnection(); statement = connection.prepareStatement(RDBMSConstants.PS_INSERT_EXCHANGE); statement.setString(1, exchange.getName()); statement.setString(2, exchange.getType().toString()); statement.executeUpdate(); connection.commit(); } catch (SQLException e) { String message = "Error occurred while storing exchange " + exchange; rollback(connection, message); throw new BrokerException(message, e); } finally { close(connection, statement); } } ExchangeDaoImpl(DataSource dataSource); @Override void persist(Exchange exchange); @Override void delete(Exchange exchange); @Override void retrieveAll(ExchangeCollector exchangeCollector);  }### Answer:
@Test(dataProvider = "exchangeData", description = "Test duplicate exchange persistence" , expectedExceptions = BrokerException.class) public void testDuplicatePersistence(String name, String type) throws Exception { Exchange exchange = ExchangeRegistry.ExchangeFactory.newInstance(name, Exchange.Type.from(type), bindingDao); exchangeDao.persist(exchange); exchangeDao.persist(exchange); }