Skip to content

Commit

Permalink
Changed packagename.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagkarlsson committed Aug 24, 2015
1 parent 75be875 commit 758afc3
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.SQLException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.function.Function;

public class Mappers {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.PreparedStatement;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import java.sql.SQLException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import org.hsqldb.Database;
import org.hsqldb.DatabaseManager;
Expand All @@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.List;

import static com.kagkarlsson.jdbc.PreparedStatementSetter.NOOP;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertThat;
Expand All @@ -41,15 +40,15 @@ public void tearDown() {

@Test
public void test_basics() {
jdbcRunner.execute("create table table1 ( column1 INT);", NOOP);
jdbcRunner.execute("create table table1 ( column1 INT);", PreparedStatementSetter.NOOP);
final int inserted = jdbcRunner.execute("insert into table1(column1) values (?)", ps -> ps.setInt(1, 1));
assertThat(inserted, is(1));

final List<Integer> rowMapped = jdbcRunner.query("select * from table1", NOOP, new TableRowMapper());
final List<Integer> rowMapped = jdbcRunner.query("select * from table1", PreparedStatementSetter.NOOP, new TableRowMapper());
assertThat(rowMapped, hasSize(1));
assertThat(rowMapped.get(0), is(1));

assertThat(jdbcRunner.query("select * from table1", NOOP, Mappers.SINGLE_INT), is(1));
assertThat(jdbcRunner.query("select * from table1", PreparedStatementSetter.NOOP, Mappers.SINGLE_INT), is(1));

final int updated = jdbcRunner.execute("update table1 set column1 = ? where column1 = ?",
ps -> {
Expand All @@ -61,16 +60,16 @@ public void test_basics() {

@Test
public void test_map_multiple_rows() {
jdbcRunner.execute("create table table1 ( column1 INT);", NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", NOOP);
jdbcRunner.execute("insert into table1(column1) values (2)", NOOP);
jdbcRunner.execute("create table table1 ( column1 INT);", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (2)", PreparedStatementSetter.NOOP);

final List<Integer> rowMapped = jdbcRunner.query("select * from table1", NOOP, new TableRowMapper());
final List<Integer> rowMapped = jdbcRunner.query("select * from table1", PreparedStatementSetter.NOOP, new TableRowMapper());
assertThat(rowMapped, hasSize(2));
assertThat(rowMapped.get(0), is(1));
assertThat(rowMapped.get(1), is(2));

final List<Integer> resultSetMapped = jdbcRunner.query("select * from table1", NOOP, new TableRowMapper());
final List<Integer> resultSetMapped = jdbcRunner.query("select * from table1", PreparedStatementSetter.NOOP, new TableRowMapper());
assertThat(resultSetMapped, hasSize(2));
assertThat(resultSetMapped.get(0), is(1));
assertThat(resultSetMapped.get(1), is(2));
Expand All @@ -80,19 +79,19 @@ public void test_map_multiple_rows() {
public void should_map_constraint_violations_to_custom_exception_for_primary_key_constraint() {
expectedException.expect(IntegrityConstraintViolation.class);

jdbcRunner.execute("create table table1 ( column1 INT PRIMARY KEY);", NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", NOOP);
jdbcRunner.execute("create table table1 ( column1 INT PRIMARY KEY);", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", PreparedStatementSetter.NOOP);
}

@Test
public void should_map_constraint_violations_to_custom_exception_for_unique_constraint_() {
expectedException.expect(IntegrityConstraintViolation.class);

jdbcRunner.execute("create table table1 ( column1 INT);", NOOP);
jdbcRunner.execute("alter table table1 add constraint col1_uidx unique (column1);", NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", NOOP);
jdbcRunner.execute("create table table1 ( column1 INT);", PreparedStatementSetter.NOOP);
jdbcRunner.execute("alter table table1 add constraint col1_uidx unique (column1);", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", PreparedStatementSetter.NOOP);
jdbcRunner.execute("insert into table1(column1) values (1)", PreparedStatementSetter.NOOP);
}

private static class TableRowMapper implements RowMapper<Integer> {
Expand All @@ -102,7 +101,7 @@ public Integer map(ResultSet rs) throws SQLException {
}
}

private static class ResultSetMapper implements com.kagkarlsson.jdbc.ResultSetMapper<List<Integer>> {
private static class ResultSetMapper implements com.github.kagkarlsson.jdbc.ResultSetMapper<List<Integer>> {

@Override
public List<Integer> map(ResultSet rs) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.kagkarlsson.jdbc;
package com.github.kagkarlsson.jdbc;

import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

import javax.sql.DataSource;
Expand Down

0 comments on commit 758afc3

Please sign in to comment.