### Question:
SpringSourceFilesGenerator implements SourceFilesGenerator { @Override public Iterable<SourceFile> generateFrom(Document radl, File baseDir) { Collection<SourceFile> result = new ArrayList<>(); Module input = new Module(); input.add(new RadlCode(radl)); Module generated = new Module(); Module skeleton = new Module(); codeGenerator.generate(Arrays.asList(input), Arrays.asList(generated, skeleton)); for (Code code : generated) { String path = codeToPath(baseDir, generatedSourceSetDir, (JavaCode)code); result.add(new GeneratedSourceFile(path, code)); } for (Code code : skeleton) { String path = codeToPath(baseDir, mainSourceSetDir, (JavaCode)code); result.add(new SourceFile(path, code)); } return result; } SpringSourceFilesGenerator(String packagePrefix, String generatedSourceSetDir, String mainSourceSetDir,
      String header);   SpringSourceFilesGenerator(CodeBaseGenerator codeGenerator, String generatedSourceSetDir, String mainSourceSetDir); @Override Iterable<SourceFile> generateFrom(Document radl, File baseDir);  }### Answer:
@Test public void generatesSourceFilesFromCode() { String basePath = RANDOM.string(); String package1 = aPackage(); String class1 = aClass(); String package2 = aPackage(); String class2 = aClass(); Code code1 = newCode(package1, class1); Code code2 = newCode(package2, class2); CodeBaseGenerator codeGenerator = mock(CodeBaseGenerator.class); Document radl = DocumentBuilder.newDocument().build(); generate(codeGenerator, Arrays.asList(code1, code2)); SourceFilesGenerator sourceFilesGenerator = new SpringSourceFilesGenerator(codeGenerator, "", ""); Iterable<SourceFile> actual = sourceFilesGenerator.generateFrom(radl, new File(basePath)); assertEquals("Source files", Arrays.asList(expectedSourceFile(basePath, package1, class1), expectedSourceFile(basePath, package2, class2)), actual); }
@Test public void generatesGeneratedSourceFileForController() throws Exception { String packageName = aPackage(); String controllerClass = aClass() + "Controller"; Code controllerCode = newCode(packageName, controllerClass); CodeBaseGenerator codeGenerator = mock(CodeBaseGenerator.class); Document radl = DocumentBuilder.newDocument().build(); generate(codeGenerator, Arrays.asList(controllerCode)); SourceFilesGenerator sourceFilesGenerator = new SpringSourceFilesGenerator(codeGenerator, "", ""); Iterable<SourceFile> actual = sourceFilesGenerator.generateFrom(radl, new File(RANDOM.string())); assertEquals("Generated source file", GeneratedSourceFile.class, actual.iterator().next().getClass()); }