use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClauseAndParameters.
@Test
public void generateSQLWithInClauseAndParameters() {
queryTemplate.setWhere("baz in ( ${para} )");
params.put("para", "test");
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE baz in ( :para )", sqlStatement.getSql());
assertEquals(1, sqlStatement.getParameters().getValues().size());
assertEquals("test", sqlStatement.getParameters().getValues().get("para"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithNotInClauseAndParametersAsListAndNeedToSplit.
@Test
public void generateSQLWithNotInClauseAndParametersAsListAndNeedToSplit() {
queryTemplate.setWhere("baz NOT IN ( ${para} )");
params.put("para", Arrays.asList("a", "b", "c", "d"));
query.setMaxInParameters(2);
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE (baz NOT IN ( :para$0,:para$1 ) AND baz NOT IN ( :para$2,:para$3 ))", sqlStatement.getSql());
assertEquals(5, sqlStatement.getParameters().getValues().size());
assertEquals(Arrays.asList("a", "b", "c", "d"), sqlStatement.getParameters().getValues().get("para"));
assertEquals("a", sqlStatement.getParameters().getValues().get("para$0"));
assertEquals("b", sqlStatement.getParameters().getValues().get("para$1"));
assertEquals("c", sqlStatement.getParameters().getValues().get("para$2"));
assertEquals("d", sqlStatement.getParameters().getValues().get("para$3"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClause.
@Test
public void generateSQLWithInClause() {
queryTemplate.setWhere("baz in ( a, b )");
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE baz in ( a, b )", sqlStatement.getSql());
assertEquals(0, sqlStatement.getParameters().getValues().size());
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClauseAndParametersAsListAndNeedToSplitMultiLine.
@Test
public void generateSQLWithInClauseAndParametersAsListAndNeedToSplitMultiLine() {
queryTemplate.setWhere("baz in \n( ${para} )");
params.put("para", Arrays.asList("a", "b", "c", "d"));
query.setMaxInParameters(2);
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE (baz in \n" + "( :para$0,:para$1 ) OR baz in \n" + "( :para$2,:para$3 ))", sqlStatement.getSql());
assertEquals(5, sqlStatement.getParameters().getValues().size());
assertEquals(Arrays.asList("a", "b", "c", "d"), sqlStatement.getParameters().getValues().get("para"));
assertEquals("a", sqlStatement.getParameters().getValues().get("para$0"));
assertEquals("b", sqlStatement.getParameters().getValues().get("para$1"));
assertEquals("c", sqlStatement.getParameters().getValues().get("para$2"));
assertEquals("d", sqlStatement.getParameters().getValues().get("para$3"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClauseAndParametersAsListAndNeedToSplit.
@Test
public void generateSQLWithInClauseAndParametersAsListAndNeedToSplit() {
queryTemplate.setWhere("baz in ( ${para} )");
params.put("para", Arrays.asList("a", "b", "c", "d"));
query.setMaxInParameters(2);
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE (baz in ( :para$0,:para$1 ) OR baz in ( :para$2,:para$3 ))", sqlStatement.getSql());
assertEquals(5, sqlStatement.getParameters().getValues().size());
assertEquals(Arrays.asList("a", "b", "c", "d"), sqlStatement.getParameters().getValues().get("para"));
assertEquals("a", sqlStatement.getParameters().getValues().get("para$0"));
assertEquals("b", sqlStatement.getParameters().getValues().get("para$1"));
assertEquals("c", sqlStatement.getParameters().getValues().get("para$2"));
assertEquals("d", sqlStatement.getParameters().getValues().get("para$3"));
}
Aggregations