FunctionConfigurationDefinitionAggregator { public FunctionConfigurationBundle aggregate(final String configDefinitionName, final VersionCorrection version) { ArgumentChecker.notNull(configDefinitionName, "configDefinitionName"); FunctionConfigurationDefinition configDefinition = _configSource.getSingle(FunctionConfigurationDefinition.class, configDefinitionName, version); FunctionConfigurationBundle bundle = new FunctionConfigurationBundle(); if (configDefinition != null) { bundle = functionAggregator(configDefinition, version); } return bundle; } FunctionConfigurationDefinitionAggregator(final ConfigSource configSource); FunctionConfigurationBundle aggregate(final String configDefinitionName, final VersionCorrection version); @Deprecated FunctionConfigurationSource aggregate(final String configDefinitionName);  }
@Test public void resolveFunctionDefinition() { when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "ROOT", VersionCorrection.LATEST)).thenReturn(ROOT_DEFINITION); when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "CF1", VersionCorrection.LATEST)).thenReturn(CF1); when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "CF2", VersionCorrection.LATEST)).thenReturn(CF2); when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "CF3", VersionCorrection.LATEST)).thenReturn(CF3); final FunctionConfigurationSource configurationSource = _functionConfigAggregator.aggregate("ROOT"); assertEquals(getExpectedFunctions(), ImmutableSet.copyOf(configurationSource.getFunctionConfiguration(Instant.now()).getFunctions())); }
@Test public void cyclicReference() { final FunctionConfigurationDefinition defA = new FunctionConfigurationDefinition("DFA", ImmutableList.<String>of("DFB"), ImmutableList.of(SF1, SF2), ImmutableList.of(PF1, PF2)); final FunctionConfigurationDefinition defB = new FunctionConfigurationDefinition("DFB", ImmutableList.<String>of("DFA"), ImmutableList.of(SF3, SF4), ImmutableList.of(PF3, PF4)); when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "DFA", VersionCorrection.LATEST)).thenReturn(defA); when(_cfgSource.getSingle(FunctionConfigurationDefinition.class, "DFB", VersionCorrection.LATEST)).thenReturn(defB); Set<FunctionConfiguration> expectedFunc = new HashSet<FunctionConfiguration>(); expectedFunc.add(SF1); expectedFunc.add(SF2); expectedFunc.add(SF3); expectedFunc.add(SF4); expectedFunc.add(PF1); expectedFunc.add(PF2); expectedFunc.add(PF3); expectedFunc.add(PF4); final FunctionConfigurationSource configurationSource = _functionConfigAggregator.aggregate("DFA"); assertEquals(expectedFunc, ImmutableSet.copyOf(configurationSource.getFunctionConfiguration(Instant.now()).getFunctions())); }