db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1848532 - /db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java
Date Sun, 09 Dec 2018 16:31:31 GMT
Author: tv
Date: Sun Dec  9 16:31:31 2018
New Revision: 1848532

URL: http://svn.apache.org/viewvc?rev=1848532&view=rev
Log:
TORQUE-354: Add doSelectAsStream() to Peers

Modified:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java?rev=1848532&r1=1848531&r2=1848532&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java
Sun Dec  9 16:31:31 2018
@@ -21,6 +21,7 @@ package org.apache.torque.generated.peer
 
 import java.sql.Connection;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.torque.BaseDatabaseTestCase;
 import org.apache.torque.TooManyRowsException;
@@ -304,6 +305,33 @@ public class SelectTest extends BaseData
     }
 
     /**
+     * Tests a select where an offset and limit is used.
+     * The test uses doSelectAsStream()
+     *
+     * @throws Exception if the test fails.
+     */
+    public void testSelectStreamOffset() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addAscendingOrderByColumn(BookPeer.TITLE);
+        criteria.setOffset(3);
+        criteria.setLimit(5);
+        BookPeer.addSelectColumns(criteria);
+
+        Connection connection = Torque.getConnection();
+        List<Book> books = BookPeer
+                .doSelectAsStream(criteria, new BookRecordMapper(), connection)
+                .collect(Collectors.toList());
+        Torque.closeConnection(connection);
+
+        assertEquals(5, books.size());
+        Book selectedBook = books.get(0);
+        assertEquals("Book 1 - Author 3", selectedBook.getTitle());
+        selectedBook = books.get(4);
+        assertEquals("Book 1 - Author 7", selectedBook.getTitle());
+    }
+
+    /**
      * Tests a partial select where only a part of the object's attributes
      * are filled and foreign columns are also read.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message