GeneratorEngine { public void generateNoA(String templateName, Path filePath, Object... templateArguments) { checkArgument(!isNullOrEmpty(templateName)); Log.errorIfNull(filePath); TemplateController tc = setup.getNewTemplateController(templateName); ASTCNode dummyAST = new ASTCNode(){ @Override public IScope getEnclosingScope() { return null; } @Override public ASTNode deepClone() { return this; } }; tc.writeArgs(templateName, filePath, dummyAST, 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);  }
@Test public void testGenerateStringBuilder() { final GeneratorSetup setup = new GeneratorSetup(); FreeMarkerTemplateEngineMock freeMarkerTemplateEngine = new FreeMarkerTemplateEngineMock(setup.getConfig()); setup.setFreeMarkerTemplateEngine(freeMarkerTemplateEngine); FileReaderWriterMock fileHandler = new FileReaderWriterMock(); setup.setFileHandler(fileHandler); GeneratorEngineMock generatorEngine = new GeneratorEngineMock(setup); StringBuilder sb = generatorEngine.generateNoA("the.Template"); assertTrue(sb.length()>0); assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator().next(); assertTrue(template.isProcessed()); assertEquals("the.Template", template.getName()); assertEquals(0, fileHandler.getStoredFilesAndContents().size()); }