package org.jdbchub.jdbc;

import org.junit.Test;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.Query;
import org.skife.jdbi.v2.util.IntegerMapper;

import java.sql.Statement;

import static java.util.Arrays.asList;
import static org.jdbchub.JdbcHubTestUtils.createTestConnection;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

public class JdbcStatementTest {

	@Test
	public void testExecuteUpdate() throws Exception {

	}

	@Test
	public void testBatch() throws Exception {
		try (JdbcConnection c = createTestConnection()) {
			Statement st = c.createStatement();
			st.addBatch("update test_items set value = 'a' where name like '%1'");
			st.addBatch("update test_items set value = 'b' where name like '%22'");
			assertArrayEquals(new int[] {3, 1}, st.executeBatch());
			Handle h = DBI.open(c);
			Query<Integer> q = h.createQuery("select count(*) from test_items where value = ?").map(IntegerMapper.FIRST);
			assertEquals(asList(1, 1, 1), q.bind(0, "a").list());
			assertEquals(asList(0, 1, 0), q.bind(0, "b").list());
		}
	}

}
@@ -110,40 +110,8 @@
 le;%0A
-import org.skife.jdbi.v2.Query;%0A
 impo
@@ -179,16 +179,78 @@
 tement;%0A
+import java.util.List;%0A%0Aimport static java.lang.String.format;
 %0Aimport 
@@ -535,16 +535,531 @@
 ption %7B%0A
+%09%09try (JdbcConnection c = createTestConnection()) %7B%0A%09%09%09Handle h = DBI.open(c);%0A%09%09%09Statement st = c.createStatement();%0A%09%09%09assertEquals(3, st.executeUpdate(updateValueSql(%22nv1%22, %22%251%22)));%0A%09%09%09assertEquals(asList(1, 1, 1), selectCountByValue(h, %22nv1%22));%0A%09%09%09assertEquals(2, st.executeUpdate(updateValueSql(%22nv2%22, %22%252_%22)));%0A%09%09%09assertEquals(asList(0, 2, 0), selectCountByValue(h, %22nv2%22));%0A%09%09%09assertEquals(0, st.executeUpdate(updateValueSql(%22nv3%22, %22%253%22)));%0A%09%09%09assertEquals(asList(0, 0, 0), selectCountByValue(h, %22nv3%22));%0A%09%09%7D
 %0A%09%7D%0A%0A%09@T
@@ -1216,64 +1216,35 @@
 tch(
-%22
 update
- test_items set value = 'a' where name like '%251'%22
+ValueSql(%22nv1%22, %22%251%22)
 );%0A%09
@@ -1261,65 +1261,36 @@
 tch(
-%22
 update
- test_items set value = 'b' where name like '
+ValueSql(%22nv2%22, %22
 %2522
-'
 %22
+)
 );%0A%09
@@ -1318,17 +1318,16 @@
 ew int%5B%5D
- 
 %7B3, 1%7D, 
@@ -1380,62 +1380,229 @@
 %0A%09%09%09
-Query%3CInteger%3E q = h.createQuery(%22select count(*) from
+assertEquals(asList(1, 1, 1), selectCountByValue(h, %22nv1%22));%0A%09%09%09assertEquals(asList(0, 1, 0), selectCountByValue(h, %22nv2%22));%0A%09%09%7D%0A%09%7D%0A%0A%09public String updateValueSql(String newValue, String nameExp) %7B%0A%09%09return format(%22update
  tes
@@ -1613,13 +1613,11 @@
 ems 
-where
+set
  val
@@ -1625,149 +1625,252 @@
 e = 
-?%22).map(IntegerMapper.FIRST);%0A%09%09%09assertEquals(asList(1, 1, 1), q.bind(0, %22a%22).list());%0A%09%09%09assertEquals(asList(0, 1, 0), q.bind(0, %22b%22
+'%25s' where name like '%25s'%22, newValue, nameExp);%0A%09%7D%0A%0A%09public List%3CInteger%3E selectCountByValue(Handle h, String value) %7B%0A%09%09return h.createQuery(%22select count(*) from test_items where value = ?%22)%0A%09%09%09%09.bind(0, value).map(IntegerMapper.FIRST
 ).list()
 );%0A%09
@@ -1865,20 +1865,15 @@
 ).list()
-);%0A%09%09%7D
+;
 %0A%09%7D%0A%0A%7D

extend JdbcStatementTest, refactoring