Skip to content

Commit 4b40daa

Browse files
committed
add tests for AbstractUnixStream class
1 parent 1fb111a commit 4b40daa

File tree

1 file changed

+309
-0
lines changed

1 file changed

+309
-0
lines changed
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
package io.github.benas.unixstream;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.mockito.Mock;
7+
import org.mockito.junit.MockitoJUnitRunner;
8+
9+
import java.util.Comparator;
10+
import java.util.function.*;
11+
import java.util.stream.Collector;
12+
import java.util.stream.Stream;
13+
14+
import static org.mockito.Mockito.verify;
15+
16+
@RunWith(MockitoJUnitRunner.class)
17+
public class AbstractUnixStreamTest {
18+
19+
@Mock
20+
private Stream<Object> stream;
21+
@Mock
22+
private Predicate<Object> predicate;
23+
@Mock
24+
private Function<Object, Object> function;
25+
@Mock
26+
private Comparator<Object> comparator;
27+
@Mock
28+
private Consumer<Object> consumer;
29+
@Mock
30+
private Collector collector;
31+
@Mock
32+
private Runnable runnable;
33+
@Mock
34+
private BinaryOperator<Object> binaryOperator;
35+
@Mock
36+
private ToIntFunction<Object> toIntFunction;
37+
@Mock
38+
private ToLongFunction<Object> toLongFunction;
39+
@Mock
40+
private ToDoubleFunction<Object> toDoubleFunction;
41+
@Mock
42+
private Function flatMapToIntFunction;
43+
@Mock
44+
private Function flatMapToLongFunction;
45+
@Mock
46+
private Function flatMapToDoubleFunction;
47+
@Mock
48+
private Function flatMapFunction;
49+
50+
private AbstractUnixStream<Object> abstractUnixStream;
51+
52+
@Before
53+
public void setUp() throws Exception {
54+
abstractUnixStream = new AbstractUnixStream<>(stream);
55+
}
56+
57+
@Test
58+
public void filter() throws Exception {
59+
abstractUnixStream.filter(predicate);
60+
61+
verify(stream).filter(predicate);
62+
}
63+
64+
@Test
65+
public void map() throws Exception {
66+
abstractUnixStream.map(function);
67+
68+
verify(stream).map(function);
69+
}
70+
71+
@Test
72+
public void flatMap() throws Exception {
73+
abstractUnixStream.flatMap(flatMapFunction);
74+
75+
verify(stream).flatMap(flatMapFunction);
76+
}
77+
78+
@Test
79+
public void distinct() throws Exception {
80+
abstractUnixStream.distinct();
81+
82+
verify(stream).distinct();
83+
}
84+
85+
@Test
86+
public void sorted() throws Exception {
87+
abstractUnixStream.sorted();
88+
89+
verify(stream).sorted();
90+
}
91+
92+
@Test
93+
public void sortedWithComparator() throws Exception {
94+
abstractUnixStream.sorted(comparator);
95+
96+
verify(stream).sorted(comparator);
97+
}
98+
99+
@Test
100+
public void peek() throws Exception {
101+
abstractUnixStream.peek(consumer);
102+
103+
verify(stream).peek(consumer);
104+
}
105+
106+
@Test
107+
public void limit() throws Exception {
108+
abstractUnixStream.limit(10);
109+
110+
verify(stream).limit(10);
111+
}
112+
113+
@Test
114+
public void skip() throws Exception {
115+
abstractUnixStream.skip(10);
116+
117+
verify(stream).skip(10);
118+
}
119+
120+
@Test
121+
public void mapToInt() throws Exception {
122+
abstractUnixStream.mapToInt(toIntFunction);
123+
124+
verify(stream).mapToInt(toIntFunction);
125+
}
126+
127+
@Test
128+
public void mapToLong() throws Exception {
129+
abstractUnixStream.mapToLong(toLongFunction);
130+
131+
verify(stream).mapToLong(toLongFunction);
132+
}
133+
134+
@Test
135+
public void mapToDouble() throws Exception {
136+
abstractUnixStream.mapToDouble(toDoubleFunction);
137+
138+
verify(stream).mapToDouble(toDoubleFunction);
139+
}
140+
141+
@Test
142+
public void flatMapToInt() throws Exception {
143+
abstractUnixStream.flatMapToInt(flatMapToIntFunction);
144+
145+
verify(stream).flatMapToInt(flatMapToIntFunction);
146+
}
147+
148+
@Test
149+
public void flatMapToLong() throws Exception {
150+
abstractUnixStream.flatMapToLong(flatMapToLongFunction);
151+
152+
verify(stream).flatMapToLong(flatMapToLongFunction);
153+
}
154+
155+
@Test
156+
public void flatMapToDouble() throws Exception {
157+
abstractUnixStream.flatMapToDouble(flatMapToDoubleFunction);
158+
159+
verify(stream).flatMapToDouble(flatMapToDoubleFunction);
160+
}
161+
162+
@Test
163+
public void forEach() throws Exception {
164+
abstractUnixStream.forEach(consumer);
165+
166+
verify(stream).forEach(consumer);
167+
}
168+
169+
@Test
170+
public void forEachOrdered() throws Exception {
171+
abstractUnixStream.forEachOrdered(consumer);
172+
173+
verify(stream).forEachOrdered(consumer);
174+
}
175+
176+
@Test
177+
public void toArray() throws Exception {
178+
abstractUnixStream.toArray();
179+
180+
verify(stream).toArray();
181+
}
182+
183+
@Test
184+
public void reduce() throws Exception {
185+
abstractUnixStream.reduce(binaryOperator);
186+
187+
verify(stream).reduce(binaryOperator);
188+
}
189+
190+
@Test
191+
public void collect() throws Exception {
192+
abstractUnixStream.collect(collector);
193+
194+
verify(stream).collect(collector);
195+
}
196+
197+
@Test
198+
public void min() throws Exception {
199+
abstractUnixStream.min(comparator);
200+
201+
verify(stream).min(comparator);
202+
}
203+
204+
@Test
205+
public void max() throws Exception {
206+
abstractUnixStream.max(comparator);
207+
208+
verify(stream).max(comparator);
209+
}
210+
211+
@Test
212+
public void count() throws Exception {
213+
abstractUnixStream.count();
214+
215+
verify(stream).count();
216+
}
217+
218+
@Test
219+
public void anyMatch() throws Exception {
220+
abstractUnixStream.anyMatch(predicate);
221+
222+
verify(stream).anyMatch(predicate);
223+
}
224+
225+
@Test
226+
public void allMatch() throws Exception {
227+
abstractUnixStream.allMatch(predicate);
228+
229+
verify(stream).allMatch(predicate);
230+
}
231+
232+
@Test
233+
public void noneMatch() throws Exception {
234+
abstractUnixStream.noneMatch(predicate);
235+
236+
verify(stream).noneMatch(predicate);
237+
}
238+
239+
@Test
240+
public void findFirst() throws Exception {
241+
abstractUnixStream.findFirst();
242+
243+
verify(stream).findFirst();
244+
}
245+
246+
@Test
247+
public void findAny() throws Exception {
248+
abstractUnixStream.findAny();
249+
250+
verify(stream).findAny();
251+
}
252+
253+
@Test
254+
public void iterator() throws Exception {
255+
abstractUnixStream.iterator();
256+
257+
verify(stream).iterator();
258+
}
259+
260+
@Test
261+
public void spliterator() throws Exception {
262+
abstractUnixStream.spliterator();
263+
264+
verify(stream).spliterator();
265+
}
266+
267+
@Test
268+
public void isParallel() throws Exception {
269+
abstractUnixStream.isParallel();
270+
271+
verify(stream).isParallel();
272+
}
273+
274+
@Test
275+
public void sequential() throws Exception {
276+
abstractUnixStream.sequential();
277+
278+
verify(stream).sequential();
279+
}
280+
281+
@Test
282+
public void parallel() throws Exception {
283+
abstractUnixStream.parallel();
284+
285+
verify(stream).parallel();
286+
}
287+
288+
@Test
289+
public void unordered() throws Exception {
290+
abstractUnixStream.unordered();
291+
292+
verify(stream).unordered();
293+
}
294+
295+
@Test
296+
public void onClose() throws Exception {
297+
abstractUnixStream.onClose(runnable);
298+
299+
verify(stream).onClose(runnable);
300+
}
301+
302+
@Test
303+
public void close() throws Exception {
304+
abstractUnixStream.close();
305+
306+
verify(stream).close();
307+
}
308+
309+
}

0 commit comments

Comments
 (0)