Skip to content

Commit

Permalink
(#28) Added getClob by index
Browse files Browse the repository at this point in the history
  • Loading branch information
svettwer committed Apr 12, 2019
1 parent 73cf049 commit 5cd5bda
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public Blob getBlob(final int parameterIndex) throws SQLException {
}

@Override
public Clob getClob(final int parameterIndex) throws SQLException {
notSupported("getClob(int parameterIndex)");
return null;
public Clob getClob(final int parameterIndex) {
prepareResultSet();
return resultSet.getClob(parameterIndex);
}

@Override
Expand Down Expand Up @@ -626,7 +626,7 @@ public void setBlob(final String parameterName, final Blob x) throws SQLExceptio
}

@Override
public void setClob(final String parameterName, final Clob x) throws SQLException {
public void setClob(final String parameterName, final Clob x) {
setParameter(parameterName, x);
}

Expand Down Expand Up @@ -731,7 +731,7 @@ private void setOutParameter(final String parameterName) {
setParameter(parameterName, "?");
}

private void prepareResultSet() throws SQLException {
private void prepareResultSet() {
if(resultSet.getRow() == 0){
resultSet.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public void testGetStringByIndex() throws SQLException {
callableStatement.getString(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getString(TEST_VALUE_INDEX);
}

Expand All @@ -456,6 +457,7 @@ public void testGetBooleanByIndex() throws SQLException {
callableStatement.getBoolean(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getBoolean(TEST_VALUE_INDEX);
}

Expand All @@ -466,6 +468,7 @@ public void testGetByteByIndex() throws SQLException {
callableStatement.getByte(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getByte(TEST_VALUE_INDEX);
}

Expand All @@ -476,6 +479,7 @@ public void testGetBytesByIndex() throws SQLException {
callableStatement.getBytes(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getBytes(TEST_VALUE_INDEX);
}

Expand All @@ -486,6 +490,7 @@ public void testGetShortByIndex() throws SQLException {
callableStatement.getShort(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getShort(TEST_VALUE_INDEX);
}

Expand All @@ -496,6 +501,7 @@ public void testGetIntByIndex() throws SQLException {
callableStatement.getInt(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getInt(TEST_VALUE_INDEX);
}

Expand All @@ -506,6 +512,7 @@ public void testGetLongByIndex() throws SQLException {
callableStatement.getLong(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getLong(TEST_VALUE_INDEX);
}

Expand All @@ -516,6 +523,7 @@ public void testGetFloatByIndex() throws SQLException {
callableStatement.getFloat(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getFloat(TEST_VALUE_INDEX);
}

Expand All @@ -526,6 +534,7 @@ public void testGetDoubleByIndex() throws SQLException {
callableStatement.getDouble(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getDouble(TEST_VALUE_INDEX);
}

Expand All @@ -540,6 +549,7 @@ public void testGetBigDecimalByIndexWithScale() throws Exception {
callableStatement.getBigDecimal(TEST_VALUE_INDEX, 2);

//THEN
verify(resultSetSpy).next();
//noinspection ResultOfMethodCallIgnored
verify(bigDecimalMock).setScale(2, RoundingMode.HALF_UP);
}
Expand All @@ -551,6 +561,7 @@ public void testGetStringByName() throws SQLException {
callableStatement.getString(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getString(TEST_VALUE_NAME);
}

Expand All @@ -561,6 +572,7 @@ public void testGetBooleanByName() throws SQLException {
callableStatement.getBoolean(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getBoolean(TEST_VALUE_NAME);
}

Expand All @@ -581,6 +593,7 @@ public void testGetShortByName() throws SQLException {
callableStatement.getShort(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getShort(TEST_VALUE_NAME);
}

Expand All @@ -591,6 +604,7 @@ public void testGetIntByName() throws SQLException {
callableStatement.getInt(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getInt(TEST_VALUE_NAME);
}

Expand All @@ -601,6 +615,7 @@ public void testGetLongByName() throws SQLException {
callableStatement.getLong(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getLong(TEST_VALUE_NAME);
}

Expand All @@ -611,6 +626,7 @@ public void testGetFloatByName() throws SQLException {
callableStatement.getFloat(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getFloat(TEST_VALUE_NAME);
}

Expand All @@ -621,6 +637,7 @@ public void testGetDoubleByName() throws SQLException {
callableStatement.getDouble(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getDouble(TEST_VALUE_NAME);
}

Expand All @@ -631,6 +648,7 @@ public void testGetBytesByName() throws SQLException {
callableStatement.getBytes(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getBytes(TEST_VALUE_NAME);
}

Expand All @@ -641,6 +659,7 @@ public void testGetObjectByName() throws SQLException {
callableStatement.getObject(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getObject(TEST_VALUE_NAME);
}

Expand All @@ -651,6 +670,7 @@ public void testGetBigDecimalByName() throws SQLException {
callableStatement.getBigDecimal(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getBigDecimal(TEST_VALUE_NAME);
}

Expand All @@ -672,6 +692,7 @@ public void testGetDateByIndex() throws SQLException {
callableStatement.getDate(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getDate(TEST_VALUE_INDEX);
}

Expand All @@ -682,6 +703,7 @@ public void testGetTimeByIndex() throws SQLException {
callableStatement.getTime(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getTime(TEST_VALUE_INDEX);
}

Expand All @@ -692,6 +714,7 @@ public void testGetTimestampByIndex() throws SQLException {
callableStatement.getTimestamp(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getTimestamp(TEST_VALUE_INDEX);
}

Expand All @@ -702,6 +725,7 @@ public void testGetObjectByIndex() throws SQLException {
callableStatement.getObject(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getObject(TEST_VALUE_INDEX);
}

Expand All @@ -712,6 +736,7 @@ public void testGetDateByName() throws SQLException {
callableStatement.getDate(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getDate(TEST_VALUE_NAME);
}

Expand All @@ -722,6 +747,7 @@ public void testGetTimeByName() throws SQLException {
callableStatement.getTime(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getTime(TEST_VALUE_NAME);
}

Expand All @@ -732,6 +758,7 @@ public void testGetTimestampByName() throws SQLException {
callableStatement.getTimestamp(TEST_VALUE_NAME);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getTimestamp(TEST_VALUE_NAME);
}

Expand Down Expand Up @@ -774,7 +801,7 @@ public void testSetLimitedClobFromReader() throws Exception {
}

@Test
public void TestNoopIfLengthExceedsInt() throws Exception {
public void testNoopIfLengthExceedsInt() throws Exception {

//GIVEN
when(lobUtils.fitsInInt(anyLong())).thenReturn(false);
Expand All @@ -787,7 +814,7 @@ public void TestNoopIfLengthExceedsInt() throws Exception {
}

@Test
public void testSetClob() throws Exception {
public void testSetClob() {

//GIVEN
final String parameterName = "myClob";
Expand All @@ -802,7 +829,7 @@ public void testSetClob() throws Exception {
}

@Test
public void setClobFromReader() throws Exception {
public void testSetClobFromReader() throws Exception {

//GIVEN
final String parameterName = "myClob";
Expand All @@ -818,6 +845,17 @@ public void setClobFromReader() throws Exception {
assertEquals(storedClob, expectedClob);
}

@Test
public void testGetClobByIndex() throws Exception {

//WHEN
callableStatement.getClob(TEST_VALUE_INDEX);

//THEN
verify(resultSetSpy).next();
verify(resultSetSpy).getClob(TEST_VALUE_INDEX);
}

@Test
public void testToString(){
ToStringVerifier
Expand Down

0 comments on commit 5cd5bda

Please sign in to comment.