@Test public void testGenerateInFile() { ASTNodeMock node = new ASTNodeMock(); final GeneratorSetup setup = new GeneratorSetup(); setup.setOutputDirectory(new File("target1")); FreeMarkerTemplateEngineMock freeMarkerTemplateEngine = new FreeMarkerTemplateEngineMock(setup.getConfig()); setup.setFreeMarkerTemplateEngine(freeMarkerTemplateEngine); FileReaderWriterMock fileHandler = new FileReaderWriterMock(); setup.setFileHandler(fileHandler); GeneratorEngineMock generatorEngine = new GeneratorEngineMock(setup); generatorEngine.generate("the.Template", Paths.get("a/GenerateInFile.test"), node); assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator().next(); assertTrue(template.isProcessed()); assertEquals("the.Template", template.getName()); assertEquals(1, fileHandler.getStoredFilesAndContents().size()); assertTrue(fileHandler.getStoredFilesAndContents().containsKey(Paths.get (new File("target1/a/GenerateInFile.test").getAbsolutePath()))); }
public void generate(String templateName, Path filePath, ASTNode node, Object... templateArguments) { Log.errorIfNull(node); checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); tc.writeArgs(templateName, filePath, node, Arrays.asList(templateArguments)); }
GeneratorEngine { public void generate(String templateName, Path filePath, ASTNode node, Object... templateArguments) { Log.errorIfNull(node); checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); tc.writeArgs(templateName, filePath, node, Arrays.asList(templateArguments)); } }
GeneratorEngine { public void generate(String templateName, Path filePath, ASTNode node, Object... templateArguments) { Log.errorIfNull(node); checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); tc.writeArgs(templateName, filePath, node, Arrays.asList(templateArguments)); } GeneratorEngine(GeneratorSetup gs); }
GeneratorEngine { public void generate(String templateName, Path filePath, ASTNode node, Object... templateArguments) { Log.errorIfNull(node); checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); tc.writeArgs(templateName, filePath, node, Arrays.asList(templateArguments)); } GeneratorEngine(GeneratorSetup gs); void generate(String templateName, Path filePath,
                       ASTNode node, Object... templateArguments); void generateNoA(String templateName, Path filePath, Object... templateArguments); void generate(String templateName, Writer writer,
                ASTNode node, Object... templateArguments); void generateNoA(String templateName, Writer writer, Object... templateArguments); StringBuilder generate(String templateName, ASTNode node, Object... templateArguments); StringBuilder generateNoA(String templateName, Object... templateArguments); }
GeneratorEngine { public void generate(String templateName, Path filePath, ASTNode node, Object... templateArguments) { Log.errorIfNull(node); checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); tc.writeArgs(templateName, filePath, node, Arrays.asList(templateArguments)); } GeneratorEngine(GeneratorSetup gs); void generate(String templateName, Path filePath,
                       ASTNode node, Object... templateArguments); void generateNoA(String templateName, Path filePath, Object... templateArguments); void generate(String templateName, Writer writer,
                ASTNode node, Object... templateArguments); void generateNoA(String templateName, Writer writer, Object... templateArguments); StringBuilder generate(String templateName, ASTNode node, Object... templateArguments); StringBuilder generateNoA(String templateName, Object... templateArguments);  }