@Test public void testCreateVariables() throws Exception { final JavaScriptVariableSource[] sources = mockSources(5); final CompositeJavaScriptVariableSource compositeSource = new CompositeJavaScriptVariableSource(sources); final Set<JavaScriptVariable> actualVariables = compositeSource.createVariables(); assertEquals(sources.length, actualVariables.size()); for (final JavaScriptVariable variable : actualVariables) { assertTrue(variable.getVariableName().startsWith("key")); assertTrue(variable.getVariableValue().startsWith("value")); } }
@Override public Set<JavaScriptVariable> createVariables() { final Set<JavaScriptVariable> variables = new HashSet<>(); for (final JavaScriptVariableSource source : sources) { variables.addAll(source.createVariables()); } return variables; }
CompositeJavaScriptVariableSource implements JavaScriptVariableSource { @Override public Set<JavaScriptVariable> createVariables() { final Set<JavaScriptVariable> variables = new HashSet<>(); for (final JavaScriptVariableSource source : sources) { variables.addAll(source.createVariables()); } return variables; } }
CompositeJavaScriptVariableSource implements JavaScriptVariableSource { @Override public Set<JavaScriptVariable> createVariables() { final Set<JavaScriptVariable> variables = new HashSet<>(); for (final JavaScriptVariableSource source : sources) { variables.addAll(source.createVariables()); } return variables; } CompositeJavaScriptVariableSource(final JavaScriptVariableSource... theSources); }
CompositeJavaScriptVariableSource implements JavaScriptVariableSource { @Override public Set<JavaScriptVariable> createVariables() { final Set<JavaScriptVariable> variables = new HashSet<>(); for (final JavaScriptVariableSource source : sources) { variables.addAll(source.createVariables()); } return variables; } CompositeJavaScriptVariableSource(final JavaScriptVariableSource... theSources); @Override Set<JavaScriptVariable> createVariables(); }
CompositeJavaScriptVariableSource implements JavaScriptVariableSource { @Override public Set<JavaScriptVariable> createVariables() { final Set<JavaScriptVariable> variables = new HashSet<>(); for (final JavaScriptVariableSource source : sources) { variables.addAll(source.createVariables()); } return variables; } CompositeJavaScriptVariableSource(final JavaScriptVariableSource... theSources); @Override Set<JavaScriptVariable> createVariables();  }