Skip to content

Commit

Permalink
(#29) improved test case by using test data instead of working on an …
Browse files Browse the repository at this point in the history
…empty DataSet object
  • Loading branch information
svettwer committed Aug 12, 2019
1 parent 9413d7c commit 7bd3b07
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,25 @@ public void testEmptyDataSetReturnsNullOnGetNextRow() {
}

@Test
public void testCursorPositionIsPreservationInCaseOfNoData(){
public void testCursorPositionIsPreservationInCaseOfNoMoreData(){

//WHEN
//GIVEN
final DataSet dataSet = createTestDataSet();
dataSet.getNextRow();

//WHEN
final Row nextRow = dataSet.getNextRow();

//THEN
assertEquals(dataSet.getCursor(), 0);
assertEquals(dataSet.getCursor(), 1);
assertNull(nextRow);
}

@Test
public void testCursorPositionMovesInCaseOfMoreData(){

//GIVEN
final Map<String, Object> testData = Collections.singletonMap("foo","bar");
final List<Row> testDataRows = Lists.newArrayList(new Row(testData));
final DataSet dataSet = new DataSet(testDataRows);
final DataSet dataSet = createTestDataSet();

//WHEN
dataSet.getNextRow();
Expand All @@ -64,4 +67,10 @@ public void testEqualsContract(){
.withIgnoredFields("cursor")
.verify();
}

private DataSet createTestDataSet() {
final Map<String, Object> testData = Collections.singletonMap("foo", "bar");
final List<Row> testDataRows = Lists.newArrayList(new Row(testData));
return new DataSet(testDataRows);
}
}

0 comments on commit 7bd3b07

Please sign in to comment.