Skip to content

Commit

Permalink
(#29) Ensure that getNextRow throws SQLException instead of IndexOutO…
Browse files Browse the repository at this point in the history
…fBounds
  • Loading branch information
svettwer committed Feb 7, 2019
1 parent 5edee36 commit 5efc24d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public class DataSet {
*/
public Row getNextRow() throws SQLException {
checkNotClosed();
return rows.get(cursor.getAndIncrement());
try{
return rows.get(cursor.getAndIncrement());
}catch (IndexOutOfBoundsException e){
throw new SQLException("No further row in dataset", e);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.consol.citrus.db.driver.dataset;

import org.testng.annotations.Test;

import java.sql.SQLException;

public class DataSetTest {

private DataSet dataSet = new DataSet();

@Test(expectedExceptions = SQLException.class)
public void emptyDataSetThrowsExceptionOnGetNextRow() throws SQLException {

//WHEN
dataSet.getNextRow();

//THEN
//exception
}

}

0 comments on commit 5efc24d

Please sign in to comment.