23
23
import static org .junit .Assert .assertNull ;
24
24
import static org .junit .Assert .assertThrows ;
25
25
import static org .mockito .ArgumentMatchers .any ;
26
- import static org .mockito .Mockito .*;
26
+ import static org .mockito .Mockito .mock ;
27
+ import static org .mockito .Mockito .times ;
28
+ import static org .mockito .Mockito .when ;
27
29
28
30
import com .google .api .core .ApiFuture ;
29
31
import com .google .api .gax .core .ExecutorProvider ;
@@ -385,7 +387,7 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable {
385
387
public void testCallbackIsNotCalledWhilePausedAndCanceled ()
386
388
throws InterruptedException , ExecutionException {
387
389
Executor executor = Executors .newSingleThreadExecutor ();
388
- ResultSet delegate = mock (ResultSet .class );
390
+ StreamingResultSet delegate = mock (StreamingResultSet .class );
389
391
390
392
final AtomicInteger callbackCounter = new AtomicInteger ();
391
393
ApiFuture <Void > callbackResult ;
@@ -396,7 +398,7 @@ public void testCallbackIsNotCalledWhilePausedAndCanceled()
396
398
when (delegate .initiateStreaming (any (AsyncResultSet .StreamMessageListener .class )))
397
399
.thenAnswer (
398
400
answer -> {
399
- rs .onStreamMessage (PartialResultSet .newBuilder ().build (), 4 , 1 , null );
401
+ rs .onStreamMessage (PartialResultSet .newBuilder ().build (), false , null );
400
402
return null ;
401
403
});
402
404
callbackResult =
@@ -512,7 +514,7 @@ public void callbackReturnsDoneBeforeEnd_shouldStopIteration() throws Exception
512
514
513
515
@ Test
514
516
public void testOnStreamMessageWhenResumeTokenIsPresent () {
515
- ResultSet delegate = mock (ResultSet .class );
517
+ StreamingResultSet delegate = mock (StreamingResultSet .class );
516
518
try (AsyncResultSetImpl rs =
517
519
new AsyncResultSetImpl (mockedProvider , delegate , AsyncResultSetImpl .DEFAULT_BUFFER_SIZE )) {
518
520
AsyncResultSet .StreamMessageRequestor streamMessageRequestor =
@@ -525,15 +527,13 @@ public void testOnStreamMessageWhenResumeTokenIsPresent() {
525
527
rs .setCallback (Executors .newSingleThreadExecutor (), ignored -> CallbackResponse .DONE );
526
528
rs .onStreamMessage (
527
529
PartialResultSet .newBuilder ().addValues (Value .newBuilder ().build ()).build (),
528
- 4 ,
529
- 1 ,
530
+ false ,
530
531
streamMessageRequestor );
531
532
Mockito .verify (streamMessageRequestor , times (1 )).requestMessages (Mockito .eq (1 ));
532
533
533
534
rs .onStreamMessage (
534
535
PartialResultSet .newBuilder ().setResumeToken (ByteString .copyFromUtf8 ("test" )).build (),
535
- 4 ,
536
- 2 ,
536
+ false ,
537
537
streamMessageRequestor );
538
538
Mockito .verify (mockedProvider .getExecutor (), times (2 )).execute (Mockito .any ());
539
539
Mockito .verify (streamMessageRequestor , times (1 )).requestMessages (Mockito .eq (1 ));
@@ -542,7 +542,7 @@ public void testOnStreamMessageWhenResumeTokenIsPresent() {
542
542
543
543
@ Test
544
544
public void testOnStreamMessageWhenCurrentBufferSizeReachedPrefetchChunkSize () {
545
- ResultSet delegate = mock (ResultSet .class );
545
+ StreamingResultSet delegate = mock (StreamingResultSet .class );
546
546
try (AsyncResultSetImpl rs =
547
547
new AsyncResultSetImpl (mockedProvider , delegate , AsyncResultSetImpl .DEFAULT_BUFFER_SIZE )) {
548
548
AsyncResultSet .StreamMessageRequestor streamMessageRequestor =
@@ -555,8 +555,7 @@ public void testOnStreamMessageWhenCurrentBufferSizeReachedPrefetchChunkSize() {
555
555
rs .setCallback (Executors .newSingleThreadExecutor (), ignored -> CallbackResponse .DONE );
556
556
rs .onStreamMessage (
557
557
PartialResultSet .newBuilder ().addValues (Value .newBuilder ().build ()).build (),
558
- 4 ,
559
- 4 ,
558
+ true ,
560
559
streamMessageRequestor );
561
560
Mockito .verify (mockedProvider .getExecutor (), times (2 )).execute (Mockito .any ());
562
561
Mockito .verify (streamMessageRequestor , times (0 )).requestMessages (Mockito .eq (1 ));
@@ -565,7 +564,7 @@ public void testOnStreamMessageWhenCurrentBufferSizeReachedPrefetchChunkSize() {
565
564
566
565
@ Test
567
566
public void testOnStreamMessageWhenAsyncResultIsCancelled () {
568
- ResultSet delegate = mock (ResultSet .class );
567
+ StreamingResultSet delegate = mock (StreamingResultSet .class );
569
568
try (AsyncResultSetImpl rs =
570
569
new AsyncResultSetImpl (mockedProvider , delegate , AsyncResultSetImpl .DEFAULT_BUFFER_SIZE )) {
571
570
AsyncResultSet .StreamMessageRequestor streamMessageRequestor =
@@ -579,8 +578,7 @@ public void testOnStreamMessageWhenAsyncResultIsCancelled() {
579
578
rs .cancel ();
580
579
rs .onStreamMessage (
581
580
PartialResultSet .newBuilder ().addValues (Value .newBuilder ().build ()).build (),
582
- 1 ,
583
- 4 ,
581
+ false ,
584
582
streamMessageRequestor );
585
583
Mockito .verify (mockedProvider .getExecutor (), times (2 )).execute (Mockito .any ());
586
584
Mockito .verify (streamMessageRequestor , times (0 )).requestMessages (Mockito .eq (1 ));
0 commit comments