when(dataSource.getConnection()).thenReturn(jdbcConnection);
PreparedStatement ps = mock(PreparedStatement.class);
doThrow(MyException.class).when(ps).setInt(anyInt(),anyInt());
when(jdbcConnection.prepareStatement(anyString())).thenReturn(ps);
Sql2o sql2o = new Sql2o(dataSource,new NoQuirks(){
@Override
public boolean returnGeneratedKeysByDefault() {
return false;
}
});