Skip to content

Commit

Permalink
CAY-2814 Select query iterator() and batchIterator() methods return i…
Browse files Browse the repository at this point in the history
…ncorrect results

 - fix tests
  • Loading branch information
stariy95 committed Nov 6, 2023
1 parent 84c6af4 commit 78883fc
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,17 @@ public void scalarQueryWithIterator() {

@Test
public void dataRowQueryWithBatchIterator() {
try (ResultBatchIterator<?> iterator = SQLSelect
try (ResultBatchIterator<DataRow> iterator = SQLSelect
.dataRowQuery("SELECT * FROM PAINTING ORDER BY PAINTING_ID")
.upperColumnNames()
.batchIterator(context, 5)) {
int count = 0;
int paintingCounter = 0;
while (iterator.hasNext()) {
count++;
List<?> rows = iterator.next();
for (Object row : rows) {
paintingCounter++;
Painting painting = context.objectFromDataRow(Painting.class, (DataRow) row);
assertEquals("painting" + paintingCounter, painting.getPaintingTitle());
List<DataRow> rows = iterator.next();
for (DataRow row : rows) {
assertEquals("painting" + row.get(Painting.PAINTING_ID_PK_COLUMN),
row.get("PAINTING_TITLE"));
}
}
assertEquals(4, count);
Expand All @@ -137,26 +136,26 @@ public void dataRowQueryWithBatchIterator() {

@Test
public void dataRowQueryWithIterator() {
try (ResultIterator<?> iterator = SQLSelect
try (ResultIterator<DataRow> iterator = SQLSelect
.dataRowQuery("SELECT * FROM PAINTING ORDER BY PAINTING_ID")
.upperColumnNames()
.iterator(context)) {
int count = 0;
int paintingCounter = 0;
while (iterator.hasNextRow()) {
count++;
paintingCounter++;
Object row = iterator.nextRow();
Painting painting = context.objectFromDataRow(Painting.class, (DataRow) row);
assertEquals("painting" + paintingCounter, painting.getPaintingTitle());
DataRow row = iterator.nextRow();
assertEquals("painting" + row.get(Painting.PAINTING_ID_PK_COLUMN),
row.get("PAINTING_TITLE"));
}
assertEquals(20, count);
}
}

@Test
public void QueryWithBatchIterator() {
public void queryWithBatchIterator() {
try (ResultBatchIterator<Painting> iterator = SQLSelect
.query(Painting.class,"SELECT * FROM PAINTING ORDER BY PAINTING_ID")
.upperColumnNames()
.batchIterator(context, 5)) {
int count = 0;
int paintingCounter = 0;
Expand All @@ -173,9 +172,10 @@ public void QueryWithBatchIterator() {
}

@Test
public void QueryWithIterator() {
public void queryWithIterator() {
try (ResultIterator<Painting> iterator = SQLSelect
.query(Painting.class, "SELECT * FROM PAINTING ORDER BY PAINTING_ID")
.upperColumnNames()
.iterator(context)) {
int count = 0;
int paintingCounter = 0;
Expand All @@ -192,7 +192,7 @@ public void QueryWithIterator() {
//MapperConversationStrategy
//MixedConversationStrategy
@Test
public void MappingWithBatchIterator() {
public void mappingWithBatchIterator() {
try (ResultBatchIterator<DTO> iterator = SQLSelect
.columnQuery( "SELECT PAINTING_TITLE, ESTIMATED_PRICE FROM PAINTING ORDER BY PAINTING_ID")
.map(this::toDto)
Expand All @@ -215,9 +215,10 @@ public void MappingWithBatchIterator() {
//MapperConversationStrategy
//MixedConversationStrategy
@Test
public void MappingWithIterator() {
public void mappingWithIterator() {
try (ResultIterator<DTO> iterator = SQLSelect
.columnQuery("SELECT PAINTING_TITLE, ESTIMATED_PRICE FROM PAINTING ORDER BY PAINTING_ID")
.upperColumnNames()
.map(this::toDto)
.iterator(context)) {
int count = 0;
Expand Down

0 comments on commit 78883fc

Please sign in to comment.