use of com.github.fabriciofx.cactoos.jdbc.result.ResultSetAsXml in project cactoos-jdbc by fabriciofx.
the class StatementSelectTest method select.
@Test
public void select() throws Exception {
try (Servers servers = new Servers(new ServerH2(), new ServerMysql(), new ServerPgsql())) {
for (final Session session : servers.sessions()) {
new StatementUpdate(session, new QuerySimple(new Joined(" ", "CREATE TABLE employee (id INT,", "name VARCHAR(50), birthday DATE,", "address VARCHAR(100),", "married BOOLEAN, salary DECIMAL(20,2),", "PRIMARY KEY (id))"))).result();
new StatementBatch(session, new QueryBatch(new Joined(" ", "INSERT INTO employee", "(id, name, birthday, address, married, salary)", "VALUES (:id, :name, :birthday, :address,", ":married, :salary)"), new ParamsNamed(new ParamInt("id", 1), new ParamText("name", "John Wick"), new ParamDate("birthday", "1980-08-15"), new ParamText("address", "Boulevard Street, 34"), new ParamBool("married", false), new ParamDecimal("salary", "13456.00")), new ParamsNamed(new ParamInt("id", 2), new ParamText("name", "Adam Park"), new ParamDate("birthday", "1985-07-09"), new ParamText("address", "Sunset Place, 14"), new ParamBool("married", true), new ParamDecimal("salary", "12345.00")))).result();
MatcherAssert.assertThat(XhtmlMatchers.xhtml(new ResultSetAsXml(new StatementSelect(session, new QuerySimple("SELECT * FROM employee")), "employees", "employee").value()), XhtmlMatchers.hasXPaths("/employees/employee/id[text()='1']", "/employees/employee/name[text()='John Wick']", String.join("", "/employees/employee/address[text()=", "'Boulevard Street, 34']"), "/employees/employee/married[text()='false']", "/employees/employee/salary[text()='13456.00']", "/employees/employee/id[text()='2']", "/employees/employee/name[text()='Adam Park']", String.join("", "/employees/employee/address[text()=", "'Sunset Place, 14']"), "/employees/employee/married[text()='true']", "/employees/employee/salary[text()='12345.00']"));
}
}
}
Aggregations