|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -49,16 +49,22 @@ public class SqlUpdateTests { |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE = |
|
|
|
private static final String UPDATE = |
|
|
|
"update seat_status set booking_id = null"; |
|
|
|
"update seat_status set booking_id = null"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE_INT = |
|
|
|
private static final String UPDATE_INT = |
|
|
|
"update seat_status set booking_id = null where performance_id = ?"; |
|
|
|
"update seat_status set booking_id = null where performance_id = ?"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE_INT_INT = |
|
|
|
private static final String UPDATE_INT_INT = |
|
|
|
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ?"; |
|
|
|
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ?"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE_NAMED_PARAMETERS = |
|
|
|
private static final String UPDATE_NAMED_PARAMETERS = |
|
|
|
"update seat_status set booking_id = null where performance_id = :perfId and price_band_id = :priceId"; |
|
|
|
"update seat_status set booking_id = null where performance_id = :perfId and price_band_id = :priceId"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE_STRING = |
|
|
|
private static final String UPDATE_STRING = |
|
|
|
"update seat_status set booking_id = null where name = ?"; |
|
|
|
"update seat_status set booking_id = null where name = ?"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String UPDATE_OBJECTS = |
|
|
|
private static final String UPDATE_OBJECTS = |
|
|
|
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ? and name = ? and confirmed = ?"; |
|
|
|
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ? and name = ? and confirmed = ?"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String INSERT_GENERATE_KEYS = |
|
|
|
private static final String INSERT_GENERATE_KEYS = |
|
|
|
"insert into show (name) values(?)"; |
|
|
|
"insert into show (name) values(?)"; |
|
|
|
|
|
|
|
|
|
|
@ -66,11 +72,16 @@ public class SqlUpdateTests { |
|
|
|
public ExpectedException thrown = ExpectedException.none(); |
|
|
|
public ExpectedException thrown = ExpectedException.none(); |
|
|
|
|
|
|
|
|
|
|
|
private DataSource dataSource; |
|
|
|
private DataSource dataSource; |
|
|
|
|
|
|
|
|
|
|
|
private Connection connection; |
|
|
|
private Connection connection; |
|
|
|
|
|
|
|
|
|
|
|
private PreparedStatement preparedStatement; |
|
|
|
private PreparedStatement preparedStatement; |
|
|
|
|
|
|
|
|
|
|
|
private ResultSet resultSet; |
|
|
|
private ResultSet resultSet; |
|
|
|
|
|
|
|
|
|
|
|
private ResultSetMetaData resultSetMetaData; |
|
|
|
private ResultSetMetaData resultSetMetaData; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
@Before |
|
|
|
public void setUp() throws Exception { |
|
|
|
public void setUp() throws Exception { |
|
|
|
dataSource = mock(DataSource.class); |
|
|
|
dataSource = mock(DataSource.class); |
|
|
@ -87,6 +98,7 @@ public class SqlUpdateTests { |
|
|
|
verify(connection).close(); |
|
|
|
verify(connection).close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testUpdate() throws SQLException { |
|
|
|
public void testUpdate() throws SQLException { |
|
|
|
given(preparedStatement.executeUpdate()).willReturn(1); |
|
|
|
given(preparedStatement.executeUpdate()).willReturn(1); |
|
|
@ -192,7 +204,7 @@ public class SqlUpdateTests { |
|
|
|
verify(preparedStatement).setObject(1, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setObject(1, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setObject(2, 1, Types.NUMERIC, 2); |
|
|
|
verify(preparedStatement).setObject(2, 1, Types.NUMERIC, 2); |
|
|
|
verify(preparedStatement).setString(3, "rod"); |
|
|
|
verify(preparedStatement).setString(3, "rod"); |
|
|
|
verify(preparedStatement).setObject(4, Boolean.TRUE, Types.BOOLEAN); |
|
|
|
verify(preparedStatement).setBoolean(4, Boolean.TRUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -231,7 +243,7 @@ public class SqlUpdateTests { |
|
|
|
verify(preparedStatement).setObject(1, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setObject(1, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setObject(2, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setObject(2, 1, Types.NUMERIC); |
|
|
|
verify(preparedStatement).setString(3, "rod"); |
|
|
|
verify(preparedStatement).setString(3, "rod"); |
|
|
|
verify(preparedStatement).setObject(4, Boolean.TRUE, Types.BOOLEAN); |
|
|
|
verify(preparedStatement).setBoolean(4, Boolean.TRUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -360,10 +372,7 @@ public class SqlUpdateTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int run(int performanceId, int type, String name, boolean confirmed) { |
|
|
|
public int run(int performanceId, int type, String name, boolean confirmed) { |
|
|
|
Object[] params = |
|
|
|
return update(performanceId, type, name, confirmed); |
|
|
|
new Object[] {performanceId, type, name, |
|
|
|
|
|
|
|
new Boolean(confirmed)}; |
|
|
|
|
|
|
|
return update(params); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -379,8 +388,7 @@ public class SqlUpdateTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int run(String name, KeyHolder generatedKeyHolder) { |
|
|
|
public int run(String name, KeyHolder generatedKeyHolder) { |
|
|
|
Object[] params = new Object[] {name}; |
|
|
|
return update(new Object[] {name}, generatedKeyHolder); |
|
|
|
return update(params, generatedKeyHolder); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -394,10 +402,7 @@ public class SqlUpdateTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int run(int performanceId, int type, String name, boolean confirmed) { |
|
|
|
public int run(int performanceId, int type, String name, boolean confirmed) { |
|
|
|
Object[] params = |
|
|
|
return update(performanceId, type, name, confirmed); |
|
|
|
new Object[] { |
|
|
|
|
|
|
|
performanceId, type, name, new Boolean(confirmed)}; |
|
|
|
|
|
|
|
return update(params); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|