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 ...");
}
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"));
}
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);
}
Aggregations