Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
ce32db4c
Commit
ce32db4c
authored
Feb 11, 2019
by
Mariusz Smykuła
Committed by
Greg Messner
Feb 11, 2019
Browse files
Verify that PagerSplitter can collect data page by page (#299)
parent
8b782fab
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java
View file @
ce32db4c
package
org.gitlab4j.api
;
import
java.util.Collections
;
import
java.util.stream.StreamSupport
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
@@ -9,6 +10,8 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
@@ -53,4 +56,23 @@ public class PagerSpliteratorTest {
assertEquals
(
NullPointerException
.
class
,
e
.
getClass
());
}
}
@Test
public
void
shouldAllowToGatherDataPageByPage
()
{
when
(
pager
.
hasNext
()).
thenReturn
(
true
);
when
(
pager
.
getTotalItems
()).
thenReturn
(
12
);
when
(
pager
.
next
())
.
thenReturn
(
asList
(
1
,
2
,
3
))
.
thenReturn
(
asList
(
4
,
5
,
6
))
.
thenReturn
(
asList
(
7
,
8
,
9
))
.
thenReturn
(
asList
(
0
,
1
,
2
));
Integer
[]
elements
=
StreamSupport
.
stream
(
new
PagerSpliterator
<
Integer
>(
pager
),
false
)
.
parallel
()
// should be ignored
.
skip
(
2
)
// should be ignored
.
limit
(
5
)
.
toArray
(
Integer
[]::
new
);
assertArrayEquals
(
new
Integer
[]{
1
,
2
,
3
,
4
,
5
},
elements
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment