AbstractConfigurationService implements ConfigurationService { @Override public List<ConfigMessage> validateTransaction(TransactionConfig config) { List<ConfigMessage> messages = new ArrayList<ConfigMessage>(); if (config.getFilter() == null || (config.getFilter().getInclusions().isEmpty() && config.getFilter().getInclusions().isEmpty())) { ConfigMessage cm = new ConfigMessage(); cm.setMessage(NO_FILTERS); messages.add(cm); } for (Processor processor : config.getProcessors()) { for (ProcessorAction action : processor.getActions()) { ProcessorActionHandler handler = ProcessorActionHandlerFactory.getHandler(action); if (handler != null) { messages.addAll(handler.init(processor)); } } } return messages; }  @Override List<ConfigMessage> validateTransaction(TransactionConfig config); @Override List<ConfigMessage> setTransactions(String tenantId, Map<String, TransactionConfig> configs);  }
@Test public void testValidateNoFilters() { TestConfigurationService cs = new TestConfigurationService(); TransactionConfig config = new TransactionConfig(); List<ConfigMessage> messages = cs.validateTransaction(config); assertNotNull(messages); assertFalse(messages.isEmpty()); }
@Test public void testValidateValid() { TestConfigurationService cs = new TestConfigurationService(); TransactionConfig config = new TransactionConfig(); config.setFilter(new Filter()); config.getFilter().getInclusions().add("myfilter"); List<ConfigMessage> messages = cs.validateTransaction(config); assertNotNull(messages); assertTrue(messages.isEmpty()); }
@Test public void testValidateSetPropertyMissingNameAndExpression() { TestConfigurationService cs = new TestConfigurationService(); TransactionConfig config = new TransactionConfig(); config.setFilter(new Filter()); config.getFilter().getInclusions().add("myfilter"); Processor processor = new Processor(); processor.setDescription("processor1"); config.getProcessors().add(processor); SetPropertyAction action = new SetPropertyAction(); action.setDescription("action1"); processor.getActions().add(action); List<ConfigMessage> messages = cs.validateTransaction(config); assertEquals(2, messages.size()); assertEquals(processor.getDescription(), messages.get(0).getProcessor()); assertEquals(processor.getDescription(), messages.get(1).getProcessor()); assertEquals(action.getDescription(), messages.get(0).getAction()); assertEquals(action.getDescription(), messages.get(1).getAction()); }