Search in sources :

Example 11 with Session

use of com.github.fabriciofx.cactoos.jdbc.Session in project cactoos-jdbc by fabriciofx.

the class PhonebookTest method renameContact.

@Test
public void renameContact() throws Exception {
    try (Servers servers = new Servers(new ServerH2(new ScriptSql(new ResourceOf(new Joined("/", "com/github/fabriciofx/cactoos/jdbc/phonebook", "phonebook-h2.sql")))), new ServerPgsql(new ScriptSql(new ResourceOf(new Joined("/", "com/github/fabriciofx/cactoos/jdbc/phonebook", "phonebook-pgsql.sql")))))) {
        for (final Session session : servers.sessions()) {
            final Phonebook phonebook = new PhonebookSql(session);
            final Contact contact = phonebook.filter("maria").iterator().next();
            contact.update(new MapOf<String, String>(new MapEntry<>("name", "Maria Lima")));
            MatcherAssert.assertThat(XhtmlMatchers.xhtml(new PhonebookSql(session).filter("maria").iterator().next().about()), XhtmlMatchers.hasXPaths("/contact/name[text()='Maria Lima']"));
        }
    }
}
Also used : ServerH2(com.github.fabriciofx.cactoos.jdbc.server.ServerH2) MapEntry(org.cactoos.map.MapEntry) PhonebookSql(com.github.fabriciofx.cactoos.jdbc.phonebook.sql.PhonebookSql) Servers(com.github.fabriciofx.cactoos.jdbc.Servers) ServerPgsql(com.github.fabriciofx.cactoos.jdbc.server.ServerPgsql) Contact(com.github.fabriciofx.cactoos.jdbc.phonebook.Contact) ScriptSql(com.github.fabriciofx.cactoos.jdbc.script.ScriptSql) Phonebook(com.github.fabriciofx.cactoos.jdbc.phonebook.Phonebook) ResourceOf(org.cactoos.io.ResourceOf) Joined(org.cactoos.text.Joined) Session(com.github.fabriciofx.cactoos.jdbc.Session) Test(org.junit.Test)

Aggregations

Session (com.github.fabriciofx.cactoos.jdbc.Session)11 Test (org.junit.Test)11 Joined (org.cactoos.text.Joined)10 QuerySimple (com.github.fabriciofx.cactoos.jdbc.query.QuerySimple)9 ParamText (com.github.fabriciofx.cactoos.jdbc.param.ParamText)8 ServerH2 (com.github.fabriciofx.cactoos.jdbc.server.ServerH2)7 ServerPgsql (com.github.fabriciofx.cactoos.jdbc.server.ServerPgsql)7 Servers (com.github.fabriciofx.cactoos.jdbc.Servers)6 ServerMysql (com.github.fabriciofx.cactoos.jdbc.server.ServerMysql)6 Server (com.github.fabriciofx.cactoos.jdbc.Server)4 ParamInt (com.github.fabriciofx.cactoos.jdbc.param.ParamInt)4 QueryKeyed (com.github.fabriciofx.cactoos.jdbc.query.QueryKeyed)4 ParamsNamed (com.github.fabriciofx.cactoos.jdbc.params.ParamsNamed)3 QueryBatch (com.github.fabriciofx.cactoos.jdbc.query.QueryBatch)3 ParamBool (com.github.fabriciofx.cactoos.jdbc.param.ParamBool)2 ParamDate (com.github.fabriciofx.cactoos.jdbc.param.ParamDate)2 ParamDecimal (com.github.fabriciofx.cactoos.jdbc.param.ParamDecimal)2 Contact (com.github.fabriciofx.cactoos.jdbc.phonebook.Contact)2 Phonebook (com.github.fabriciofx.cactoos.jdbc.phonebook.Phonebook)2 PhonebookSql (com.github.fabriciofx.cactoos.jdbc.phonebook.sql.PhonebookSql)2