Search in sources :

Example 66 with Template

use of org.apache.velocity.Template in project selenium-tests by Wikia.

the class VelocityWrapper method fillLogRow.

static void fillLogRow(List<LogData> logData, String command, String description) {
    StringBuilder builder = new StringBuilder();
    Template t = velocityEngine.getTemplate(LOG_ROW_TEMPLATE_PATH);
    VelocityContext context = new VelocityContext();
    context.put("className", "\"" + logData.stream().map(e -> e.cssClass()).collect(Collectors.joining(" ")) + "\"");
    context.put("command", command);
    context.put("description", description);
    StringWriter writer = new StringWriter();
    t.merge(context, writer);
    builder.append(writer.toString());
    CommonUtils.appendTextToFile(Log.LOG_PATH, builder.toString());
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext) Template(org.apache.velocity.Template)

Example 67 with Template

use of org.apache.velocity.Template in project selenium-tests by Wikia.

the class VelocityWrapper method fillLastLogRow.

static String fillLastLogRow() {
    StringBuilder builder = new StringBuilder();
    Template t = velocityEngine.getTemplate(LAST_LOG_ROW_TEMPLATE_PATH);
    VelocityContext context = new VelocityContext();
    StringWriter writer = new StringWriter();
    t.merge(context, writer);
    builder.append(writer.toString());
    return builder.toString();
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext) Template(org.apache.velocity.Template)

Example 68 with Template

use of org.apache.velocity.Template in project selenium-tests by Wikia.

the class VelocityWrapper method fillLink.

public static String fillLink(String link, String label) {
    StringBuilder builder = new StringBuilder();
    Template t = velocityEngine.getTemplate(LINK_TEMPLATE_PATH);
    VelocityContext context = new VelocityContext();
    context.put("link", link);
    context.put("label", label);
    StringWriter writer = new StringWriter();
    t.merge(context, writer);
    builder.append(writer.toString());
    return builder.toString();
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext) Template(org.apache.velocity.Template)

Example 69 with Template

use of org.apache.velocity.Template in project selenium-tests by Wikia.

the class VelocityWrapper method fillHeader.

static String fillHeader(String date, String polishDate, String browser, String os, String testingEnvironmentUrl, String testingEnvironment, String testedVersion, String mercuryVersion) {
    StringBuilder builder = new StringBuilder();
    Template t = velocityEngine.getTemplate(HEADER_TEMPLATE_PATH);
    VelocityContext context = new VelocityContext();
    context.put("date", date);
    context.put("polishDate", polishDate);
    context.put("browser", browser);
    context.put("os", os);
    context.put("testingEnvironmentUrl", testingEnvironmentUrl);
    context.put("testingEnvironment", testingEnvironment);
    context.put("testedVersion", testedVersion);
    context.put("mobileWikiVersion", mercuryVersion);
    StringWriter writer = new StringWriter();
    t.merge(context, writer);
    builder.append(writer.toString());
    return builder.toString();
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext) Template(org.apache.velocity.Template)

Example 70 with Template

use of org.apache.velocity.Template in project selenium-tests by Wikia.

the class VelocityWrapper method fillLogRowWithScreenshot.

static void fillLogRowWithScreenshot(List<LogData> logData, String command, String description, long imageCounter) {
    StringBuilder builder = new StringBuilder();
    Template t = velocityEngine.getTemplate(LOG_ROW_WITH_SCREENSHOT_TEMPLATE_PATH);
    VelocityContext context = new VelocityContext();
    context.put("className", "\"" + logData.stream().map(e -> e.cssClass()).collect(Collectors.joining(" ")) + "\"");
    context.put("command", command);
    context.put("description", description);
    context.put("imageCounter", String.valueOf(imageCounter));
    StringWriter writer = new StringWriter();
    t.merge(context, writer);
    builder.append(writer.toString());
    CommonUtils.appendTextToFile(Log.LOG_PATH, builder.toString());
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext) Template(org.apache.velocity.Template)

Aggregations

Template (org.apache.velocity.Template)160 VelocityContext (org.apache.velocity.VelocityContext)118 StringWriter (java.io.StringWriter)76 VelocityEngine (org.apache.velocity.app.VelocityEngine)39 Test (org.junit.Test)33 File (java.io.File)21 IOException (java.io.IOException)19 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)17 Writer (java.io.Writer)14 FileWriter (java.io.FileWriter)12 ClasspathResourceLoader (org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader)12 ParseErrorException (org.apache.velocity.exception.ParseErrorException)11 MethodInvocationException (org.apache.velocity.exception.MethodInvocationException)9 APITemplateException (org.wso2.carbon.apimgt.impl.template.APITemplateException)9 FileOutputStream (java.io.FileOutputStream)8 PrintWriter (java.io.PrintWriter)8 Map (java.util.Map)8 Properties (java.util.Properties)8 VelocityException (org.apache.velocity.exception.VelocityException)7 OutputStreamWriter (java.io.OutputStreamWriter)6