Search in sources :

Example 1 with TemplateGenerator

use of com.github.mgramin.sqlboot.template.generator.TemplateGenerator in project sql-boot by sql-boot.

the class GroovyTemplateGeneratorTest method processLoweCase.

@Test
public void processLoweCase() throws BootException {
    Map<String, Object> maps = of("column", "id", "table", "persons", "schema", "public");
    TemplateGenerator templateGenerator = new GroovyTemplateGenerator("create table ${table.toLowerCase()} ...");
    assertEquals(templateGenerator.generate(maps), "create table persons ...");
}
Also used : TemplateGenerator(com.github.mgramin.sqlboot.template.generator.TemplateGenerator) Test(org.junit.Test)

Example 2 with TemplateGenerator

use of com.github.mgramin.sqlboot.template.generator.TemplateGenerator in project sql-boot by sql-boot.

the class GroovyTemplateGeneratorTest method getAllProperties.

@Test
public void getAllProperties() throws BootException {
    String txt = "... where lower(c.table_schema) like '$schema'\n" + "and lower(c.table_name) like '$table'\n" + "and lower(c.column_name) like '$column'";
    TemplateGenerator templateGenerator = new GroovyTemplateGenerator(txt);
    assertEquals(templateGenerator.properties(), Arrays.asList("schema", "table", "column"));
}
Also used : TemplateGenerator(com.github.mgramin.sqlboot.template.generator.TemplateGenerator) Test(org.junit.Test)

Example 3 with TemplateGenerator

use of com.github.mgramin.sqlboot.template.generator.TemplateGenerator in project sql-boot by sql-boot.

the class GroovyTemplateGeneratorTest method process.

@Test
public void process() throws BootException {
    String txt = "... where lower(c.table_schema) like '$schema'\n" + "and lower(c.table_name) like '$table'\n" + "and lower(c.column_name) like '$column'";
    String result = "... where lower(c.table_schema) like 'public'\n" + "and lower(c.table_name) like 'persons'\n" + "and lower(c.column_name) like 'id'";
    Map<String, Object> maps = of("column", "id", "table", "persons", "schema", "public");
    TemplateGenerator templateGenerator = new GroovyTemplateGenerator(txt);
    assertEquals(templateGenerator.generate(maps), result);
}
Also used : TemplateGenerator(com.github.mgramin.sqlboot.template.generator.TemplateGenerator) Test(org.junit.Test)

Aggregations

TemplateGenerator (com.github.mgramin.sqlboot.template.generator.TemplateGenerator)3 Test (org.junit.Test)3