Last active
February 27, 2018 12:50
-
-
Save dileeph/a3ef2c97d351932ea41c1888e8959c63 to your computer and use it in GitHub Desktop.
Query builder test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import org.junit.Test; | |
public class QueryBuilderTest { | |
@Test | |
public void testQB() { | |
String sql = "select x from "; | |
String parameterValue = "john"; | |
Query finalQuery = new QueryBuilder(sql) | |
.addQuery(" b, c where d = :dname", "dname", | |
() -> parameterValue.toUpperCase(), | |
() -> parameterValue != null && !parameterValue.equals("jane")) | |
.addQuery(" and p = :pname", "pname", "tom") | |
.build(); | |
System.out.println(finalQuery ); | |
} | |
@Test(expected=IOException.class) | |
public void testQB2() throws Exception { | |
String sql = "select x from "; | |
String parameterValue = "jane"; | |
Query finalQuery = new QueryBuilder(sql) | |
.addQuery(" b, c where d = :dname", "dname", | |
() -> parameterValue.toUpperCase(), | |
() -> parameterValue != null && !parameterValue.equals("jane"), | |
() -> new IOException("dddd")) | |
.addQuery(" and p = :pname", "pname", | |
() -> "tom").build(); | |
System.out.println(finalQuery ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment