EndpointsSectionProcessingStrategy implements ISectionStrategy { @Override public void onLoadConfig(final IObject config) throws ConfigurationProcessingException { try { List<IObject> endpointObjects = (List<IObject>) config.getValue(name); IChainStorage chainStorage = IOC.resolve(IOC.resolve(IOC.getKeyForKeyStorage(), IChainStorage.class.getCanonicalName())); IQueue<ITask> queue = IOC.resolve(Keys.getOrAdd("task_queue")); for (IObject endpoint : endpointObjects) { String type = (String) endpoint.getValue(typeFieldName); String startChainName = (String) endpoint.getValue(startChainNameFieldName); Object mapId = IOC.resolve(Keys.getOrAdd("chain_id_from_map_name"), startChainName); IReceiverChain chain = chainStorage.resolve(mapId); endpoint.setValue(startChainNameFieldName, chain); endpoint.setValue(queueFieldName, queue); IAsyncService endpointService = IOC.resolve(Keys.getOrAdd(type + "_endpoint"), endpoint); endpointService.start(); } } catch (ReadValueException | InvalidArgumentException e) { throw new ConfigurationProcessingException("Error occurred loading \"endpoint\" configuration section.", e); } catch (ResolutionException e) { throw new ConfigurationProcessingException("Error occurred resolving \"endpoint\".", e); } catch (ChainNotFoundException e) { throw new ConfigurationProcessingException("Error occurred resolving \"chain\".", e); } catch (ChangeValueException e) { e.printStackTrace(); } } EndpointsSectionProcessingStrategy(); @Override void onLoadConfig(final IObject config); @Override IFieldName getSectionName();  }
@Test public void testLoadingConfig() throws InvalidArgumentException, ResolutionException, ConfigurationProcessingException, ChainNotFoundException { when(chainStorage.resolve(mapId)).thenReturn(receiverChain); DSObject config = new DSObject("\n" + " {\n" + " \"endpoints\": [\n" + " {\n" + " \"name\": \"enpointName\"," + " \"type\": \"http\",\n" + " \"port\": 8080,\n" + " \"startChain\": \"mainChain\",\n" + " \"maxContentLength\": 4098,\n" + " \"stackDepth\": 5\n" + " }\n" + " ]\n" + " }"); EndpointsSectionProcessingStrategy strategy = new EndpointsSectionProcessingStrategy(); strategy.onLoadConfig(config); }