3030import org .jboss .weld .junit5 .auto .AddExtensions ;
3131import org .jboss .weld .junit5 .auto .AddPackages ;
3232import org .jboss .weld .junit5 .auto .EnableAutoWeld ;
33+ import org .junit .jupiter .api .BeforeEach ;
3334import org .junit .jupiter .api .Test ;
3435import org .junit .jupiter .api .condition .EnabledIfSystemProperty ;
3536
37+ import java .util .List ;
3638import java .util .Optional ;
3739
3840import static java .util .UUID .randomUUID ;
@@ -61,6 +63,11 @@ class ArangoDBTemplateIntegrationTest {
6163 System .setProperty (MappingConfigurations .DOCUMENT_DATABASE .get (), "library" );
6264 }
6365
66+ @ BeforeEach
67+ void setUp () {
68+ this .template .delete (Book .class ).execute ();
69+ }
70+
6471 @ Test
6572 void shouldInsert () {
6673 Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 );
@@ -112,7 +119,7 @@ void shouldDelete() {
112119 }
113120
114121 @ Test
115- void shouldDeleteAll (){
122+ void shouldDeleteAll () {
116123 for (int index = 0 ; index < 20 ; index ++) {
117124 Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 );
118125 assertThat (template .insert (book ))
@@ -126,7 +133,7 @@ void shouldDeleteAll(){
126133
127134
128135 @ Test
129- void shouldUpdateNullValues (){
136+ void shouldUpdateNullValues () {
130137 var book = new Book (randomUUID ().toString (), "Effective Java" , 1 );
131138 template .insert (book );
132139 template .update (new Book (book .id (), null , 2 ));
@@ -138,7 +145,57 @@ void shouldUpdateNullValues(){
138145 softly .assertThat (optional ).get ().extracting (Book ::edition ).isEqualTo (2 );
139146 });
140147 }
141-
142148
149+ @ Test
150+ void shouldExecuteLimit () {
151+
152+ for (int index = 1 ; index < 10 ; index ++) {
153+ var book = new Book (randomUUID ().toString (), "Effective Java" , index );
154+ template .insert (book );
155+ }
156+
157+ List <Book > books = template .select (Book .class ).orderBy ("edition" )
158+ .asc ().limit (4 ).result ();
143159
160+ SoftAssertions .assertSoftly (soft -> {
161+ soft .assertThat (books ).hasSize (4 );
162+ var editions = books .stream ().map (Book ::edition ).toList ();
163+ soft .assertThat (editions ).hasSize (4 ).contains (1 , 2 , 3 , 4 );
164+ });
165+
166+ }
167+
168+ @ Test
169+ void shouldExecuteSkip () {
170+ for (int index = 1 ; index < 10 ; index ++) {
171+ var book = new Book (randomUUID ().toString (), "Effective Java" , index );
172+ template .insert (book );
173+ }
174+
175+ List <Book > books = template .select (Book .class ).orderBy ("edition" )
176+ .asc ().skip (4 ).result ();
177+
178+ SoftAssertions .assertSoftly (soft -> {
179+ soft .assertThat (books ).hasSize (5 );
180+ var editions = books .stream ().map (Book ::edition ).toList ();
181+ soft .assertThat (editions ).hasSize (5 ).contains (5 , 6 , 7 , 8 , 9 );
182+ });
183+ }
184+
185+ @ Test
186+ void shouldExecuteLimitStart () {
187+ for (int index = 1 ; index < 10 ; index ++) {
188+ var book = new Book (randomUUID ().toString (), "Effective Java" , index );
189+ template .insert (book );
190+ }
191+
192+ List <Book > books = template .select (Book .class ).orderBy ("edition" )
193+ .asc ().skip (4 ).limit (3 ).result ();
194+
195+ SoftAssertions .assertSoftly (soft -> {
196+ soft .assertThat (books ).hasSize (3 );
197+ var editions = books .stream ().map (Book ::edition ).toList ();
198+ soft .assertThat (editions ).hasSize (3 ).contains (5 , 6 , 7 );
199+ });
200+ }
144201}
0 commit comments