@Test public void testWriteArgs() { String TEMPLATE_NAME = "the.Template"; tc.writeArgs(TEMPLATE_NAME, "path.to.file", ".ext", ASTNodeMock.INSTANCE, new ArrayList<>()); assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator() .next(); assertTrue(template.isProcessed()); assertEquals(TEMPLATE_NAME, template.getName()); assertNotNull(template.getData()); assertEquals(1, fileHandler.getStoredFilesAndContents().size()); Path writtenFilePath = Paths.get(TARGET_DIR.getAbsolutePath(), "path/to/file.ext"); assertTrue(fileHandler.getStoredFilesAndContents().containsKey(writtenFilePath)); assertEquals("Content of template: " + TEMPLATE_NAME, fileHandler.getContentForFile(writtenFilePath.toString()).get()); }
public void writeArgs(final String templateName, final String qualifiedFileName, final String fileExtension, final ASTNode ast, final List<Object> templateArguments) { String fileExtensionWithDot = Strings.nullToEmpty(fileExtension); if (fileExtensionWithDot.startsWith(".")) { fileExtensionWithDot = fileExtensionWithDot.substring(1); } final String filePathStr = Names.getPathFromPackage(qualifiedFileName) + "." + fileExtensionWithDot; final Path filePath = Paths.get(filePathStr); writeArgs(templateName, filePath, ast, templateArguments); }
TemplateController { public void writeArgs(final String templateName, final String qualifiedFileName, final String fileExtension, final ASTNode ast, final List<Object> templateArguments) { String fileExtensionWithDot = Strings.nullToEmpty(fileExtension); if (fileExtensionWithDot.startsWith(".")) { fileExtensionWithDot = fileExtensionWithDot.substring(1); } final String filePathStr = Names.getPathFromPackage(qualifiedFileName) + "." + fileExtensionWithDot; final Path filePath = Paths.get(filePathStr); writeArgs(templateName, filePath, ast, templateArguments); } }
TemplateController { public void writeArgs(final String templateName, final String qualifiedFileName, final String fileExtension, final ASTNode ast, final List<Object> templateArguments) { String fileExtensionWithDot = Strings.nullToEmpty(fileExtension); if (fileExtensionWithDot.startsWith(".")) { fileExtensionWithDot = fileExtensionWithDot.substring(1); } final String filePathStr = Names.getPathFromPackage(qualifiedFileName) + "." + fileExtensionWithDot; final Path filePath = Paths.get(filePathStr); writeArgs(templateName, filePath, ast, templateArguments); } TemplateController(GeneratorSetup setup, String templatename); }
TemplateController { public void writeArgs(final String templateName, final String qualifiedFileName, final String fileExtension, final ASTNode ast, final List<Object> templateArguments) { String fileExtensionWithDot = Strings.nullToEmpty(fileExtension); if (fileExtensionWithDot.startsWith(".")) { fileExtensionWithDot = fileExtensionWithDot.substring(1); } final String filePathStr = Names.getPathFromPackage(qualifiedFileName) + "." + fileExtensionWithDot; final Path filePath = Paths.get(filePathStr); writeArgs(templateName, filePath, ast, templateArguments); } TemplateController(GeneratorSetup setup, String templatename); GeneratorSetup getGeneratorSetup(); String getTemplatename(); StringBuilder include(List<String> templatenames, List<ASTNode> astlist); void signature(List<String> parameterNames); void signature(String... parameterName); StringBuilder include(String templateName); StringBuilder include(List<String> templateNames); StringBuilder include(List<String> templateNames, ASTNode ast); StringBuilder include(String templateName, List<ASTNode> astlist); StringBuilder include(String templateName, ASTNode ast); StringBuilder includeArgs(String templateName, ASTNode node, List<Object> templateArguments); StringBuilder includeArgs(String templateName, List<Object> templateArguments); StringBuilder includeArgs(String templateName, String... templateArgument); void include(Object empty1, Object empty2); void write(String templateName, String qualifiedFileName, ASTNode ast); void write(String templateName, String qualifiedFileName, String fileExtension, ASTNode ast); void write(final String templateName, final Path filePath, final ASTNode ast); void writeArgs(final String templateName, final String qualifiedFileName,
                        final String fileExtension, final ASTNode ast, final List<Object> templateArguments); void writeArgs(final String templateName, final Path filePath, final ASTNode ast,
                        final List<Object> templateArguments); Object instantiate(String className); boolean existsHandwrittenFile(String filename); boolean existsHandwrittenClass(String qualifiedName,
      String extension); boolean existsHandwrittenClass(String qualifiedName); Object instantiate(String className, List<Object> params); void trace(String msg, String logName); void debug(String msg, String logName); void info(String msg, String logName); void warn(String msg); void error(String msg); }
TemplateController { public void writeArgs(final String templateName, final String qualifiedFileName, final String fileExtension, final ASTNode ast, final List<Object> templateArguments) { String fileExtensionWithDot = Strings.nullToEmpty(fileExtension); if (fileExtensionWithDot.startsWith(".")) { fileExtensionWithDot = fileExtensionWithDot.substring(1); } final String filePathStr = Names.getPathFromPackage(qualifiedFileName) + "." + fileExtensionWithDot; final Path filePath = Paths.get(filePathStr); writeArgs(templateName, filePath, ast, templateArguments); } TemplateController(GeneratorSetup setup, String templatename); GeneratorSetup getGeneratorSetup(); String getTemplatename(); StringBuilder include(List<String> templatenames, List<ASTNode> astlist); void signature(List<String> parameterNames); void signature(String... parameterName); StringBuilder include(String templateName); StringBuilder include(List<String> templateNames); StringBuilder include(List<String> templateNames, ASTNode ast); StringBuilder include(String templateName, List<ASTNode> astlist); StringBuilder include(String templateName, ASTNode ast); StringBuilder includeArgs(String templateName, ASTNode node, List<Object> templateArguments); StringBuilder includeArgs(String templateName, List<Object> templateArguments); StringBuilder includeArgs(String templateName, String... templateArgument); void include(Object empty1, Object empty2); void write(String templateName, String qualifiedFileName, ASTNode ast); void write(String templateName, String qualifiedFileName, String fileExtension, ASTNode ast); void write(final String templateName, final Path filePath, final ASTNode ast); void writeArgs(final String templateName, final String qualifiedFileName,
                        final String fileExtension, final ASTNode ast, final List<Object> templateArguments); void writeArgs(final String templateName, final Path filePath, final ASTNode ast,
                        final List<Object> templateArguments); Object instantiate(String className); boolean existsHandwrittenFile(String filename); boolean existsHandwrittenClass(String qualifiedName,
      String extension); boolean existsHandwrittenClass(String qualifiedName); Object instantiate(String className, List<Object> params); void trace(String msg, String logName); void debug(String msg, String logName); void info(String msg, String logName); void warn(String msg); void error(String msg); static final String AST; static final String TC; static final String GLEX; }