32
32
33
33
import java .util .Iterator ;
34
34
import java .util .Map ;
35
+ import java .util .function .Consumer ;
35
36
import java .util .function .Function ;
36
37
import java .util .function .Predicate ;
37
38
42
43
import static org .junit .Assert .assertFalse ;
43
44
import static org .junit .Assert .assertTrue ;
44
45
import static org .mockito .Mockito .atMost ;
46
+ import static org .mockito .Mockito .doCallRealMethod ;
45
47
import static org .mockito .Mockito .mock ;
46
48
import static org .mockito .Mockito .verify ;
47
49
import static org .mockito .Mockito .when ;
@@ -293,7 +295,8 @@ public void count() throws Exception {
293
295
Iterator <int []> iterator = mock (Iterator .class );
294
296
when (iterable .iterator ()).thenReturn (iterator );
295
297
when (iterator .hasNext ()).thenReturn (true , true , true , true , true , false );
296
- when (iterator .next ()).thenReturn (new int [0 ]);
298
+ doCallRealMethod ().when (iterator )
299
+ .forEachRemaining (ArgumentMatchers .any (Consumer .class ));
297
300
298
301
Mappings ms = new Mappings (mock (IAtomContainer .class ), mock (IAtomContainer .class ), iterable );
299
302
assertThat (ms .count (), is (5 ));
@@ -306,6 +309,8 @@ public void countUnique() throws Exception {
306
309
Iterator <int []> iterator = mock (Iterator .class );
307
310
when (iterable .iterator ()).thenReturn (iterator );
308
311
when (iterator .hasNext ()).thenReturn (true , true , true , true , false );
312
+ doCallRealMethod ().when (iterator )
313
+ .forEachRemaining (ArgumentMatchers .any (Consumer .class ));
309
314
310
315
int [] p1 = {0 , 1 , 2 };
311
316
int [] p2 = {0 , 2 , 1 };
0 commit comments