@@ -103,7 +103,10 @@ public void setUp() {
103103 systemExecutor = new FakeScheduledExecutorService ();
104104 executor = new FakeScheduledExecutorService ();
105105 clock = systemExecutor .getClock ();
106- mockSubscriberStub = mock (SubscriberStub .class , RETURNS_DEEP_STUBS );
106+ mockSubscriberStub =
107+ mock (
108+ SubscriberStub .class ,
109+ withSettings ().withoutAnnotations ().defaultAnswer (RETURNS_DEEP_STUBS ));
107110 }
108111
109112 @ After
@@ -128,7 +131,8 @@ public void testRunShutdown_TimeoutMet() throws Exception {
128131 SubscriberShutdownSettings shutdownSettings =
129132 SubscriberShutdownSettings .newBuilder ().setTimeout (Duration .ofSeconds (10 )).build ();
130133 StreamingSubscriberConnection .Builder builder =
131- StreamingSubscriberConnection .newBuilder (mock (MessageReceiverWithAckResponse .class ));
134+ StreamingSubscriberConnection .newBuilder (
135+ mock (MessageReceiverWithAckResponse .class , withSettings ().withoutAnnotations ()));
132136 builder .setSubscriberShutdownSettings (shutdownSettings );
133137 StreamingSubscriberConnection streamingSubscriberConnection =
134138 getStreamingSubscriberConnectionFromBuilder (builder );
@@ -149,7 +153,8 @@ public void testRunShutdown_TimeoutExceeded() throws Exception {
149153 SubscriberShutdownSettings shutdownSettings =
150154 SubscriberShutdownSettings .newBuilder ().setTimeout (Duration .ofSeconds (2 )).build ();
151155 StreamingSubscriberConnection .Builder builder =
152- StreamingSubscriberConnection .newBuilder (mock (MessageReceiverWithAckResponse .class ));
156+ StreamingSubscriberConnection .newBuilder (
157+ mock (MessageReceiverWithAckResponse .class , withSettings ().withoutAnnotations ()));
153158 StreamingSubscriberConnection streamingSubscriberConnection =
154159 getStreamingSubscriberConnectionFromBuilder (builder , shutdownSettings );
155160 streamingSubscriberConnection .setExactlyOnceDeliveryEnabled (true );
@@ -199,11 +204,13 @@ public void testAckDuringNackImmediatelyShutdown() throws Exception {
199204 .setMode (SubscriberShutdownSettings .ShutdownMode .NACK_IMMEDIATELY )
200205 .build ();
201206
202- MessageDispatcher mockMessageDispatcher = mock (MessageDispatcher .class );
207+ MessageDispatcher mockMessageDispatcher =
208+ mock (MessageDispatcher .class , withSettings ().withoutAnnotations ());
203209 when (mockMessageDispatcher .getNackImmediatelyShutdownInProgress ()).thenReturn (true );
204210
205211 StreamingSubscriberConnection .Builder builder =
206- StreamingSubscriberConnection .newBuilder (mock (MessageReceiverWithAckResponse .class ));
212+ StreamingSubscriberConnection .newBuilder (
213+ mock (MessageReceiverWithAckResponse .class , withSettings ().withoutAnnotations ()));
207214 StreamingSubscriberConnection streamingSubscriberConnection =
208215 getStreamingSubscriberConnectionFromBuilder (builder , shutdownSettings );
209216
@@ -687,8 +694,9 @@ public void testMaxPerRequestChanges() {
687694 @ Test
688695 public void testClientPinger_pingSent () {
689696 BidiStreamingCallable <StreamingPullRequest , StreamingPullResponse > mockStreamingCallable =
690- mock (BidiStreamingCallable .class );
691- ClientStream <StreamingPullRequest > mockClientStream = mock (ClientStream .class );
697+ mock (BidiStreamingCallable .class , withSettings ().withoutAnnotations ());
698+ ClientStream <StreamingPullRequest > mockClientStream =
699+ mock (ClientStream .class , withSettings ().withoutAnnotations ());
692700 when (mockSubscriberStub .streamingPullCallable ()).thenReturn (mockStreamingCallable );
693701 when (mockStreamingCallable .splitCall (any (ResponseObserver .class ), any ()))
694702 .thenReturn (mockClientStream );
@@ -730,8 +738,9 @@ public void testClientPinger_pingSent() {
730738 @ Test
731739 public void testClientPinger_pingsNotSentWhenDisabled () {
732740 BidiStreamingCallable <StreamingPullRequest , StreamingPullResponse > mockStreamingCallable =
733- mock (BidiStreamingCallable .class );
734- ClientStream <StreamingPullRequest > mockClientStream = mock (ClientStream .class );
741+ mock (BidiStreamingCallable .class , withSettings ().withoutAnnotations ());
742+ ClientStream <StreamingPullRequest > mockClientStream =
743+ mock (ClientStream .class , withSettings ().withoutAnnotations ());
735744 when (mockSubscriberStub .streamingPullCallable ()).thenReturn (mockStreamingCallable );
736745 when (mockStreamingCallable .splitCall (any (ResponseObserver .class ), any ()))
737746 .thenReturn (mockClientStream );
@@ -755,8 +764,9 @@ public void testClientPinger_pingsNotSentWhenDisabled() {
755764 @ Test
756765 public void testServerMonitor_timesOut () {
757766 BidiStreamingCallable <StreamingPullRequest , StreamingPullResponse > mockStreamingCallable =
758- mock (BidiStreamingCallable .class );
759- ClientStream <StreamingPullRequest > mockClientStream = mock (ClientStream .class );
767+ mock (BidiStreamingCallable .class , withSettings ().withoutAnnotations ());
768+ ClientStream <StreamingPullRequest > mockClientStream =
769+ mock (ClientStream .class , withSettings ().withoutAnnotations ());
760770 ArgumentCaptor <ResponseObserver <StreamingPullResponse >> observerCaptor =
761771 ArgumentCaptor .forClass (ResponseObserver .class );
762772 when (mockSubscriberStub .streamingPullCallable ()).thenReturn (mockStreamingCallable );
@@ -786,7 +796,8 @@ public void testServerMonitor_timesOut() {
786796 streamingSubscriberConnection .awaitRunning ();
787797
788798 ResponseObserver <StreamingPullResponse > observer = observerCaptor .getValue ();
789- StreamController mockController = mock (StreamController .class );
799+ StreamController mockController =
800+ mock (StreamController .class , withSettings ().withoutAnnotations ());
790801 observer .onStart (mockController );
791802
792803 systemExecutor .advanceTime (CLIENT_PING_INTERVAL );
@@ -803,8 +814,9 @@ public void testServerMonitor_timesOut() {
803814 @ Test
804815 public void testServerMonitor_doesNotTimeOutIfResponseReceived () {
805816 BidiStreamingCallable <StreamingPullRequest , StreamingPullResponse > mockStreamingCallable =
806- mock (BidiStreamingCallable .class );
807- ClientStream <StreamingPullRequest > mockClientStream = mock (ClientStream .class );
817+ mock (BidiStreamingCallable .class , withSettings ().withoutAnnotations ());
818+ ClientStream <StreamingPullRequest > mockClientStream =
819+ mock (ClientStream .class , withSettings ().withoutAnnotations ());
808820 ArgumentCaptor <ResponseObserver <StreamingPullResponse >> observerCaptor =
809821 ArgumentCaptor .forClass (ResponseObserver .class );
810822 when (mockSubscriberStub .streamingPullCallable ()).thenReturn (mockStreamingCallable );
@@ -818,7 +830,8 @@ public void testServerMonitor_doesNotTimeOutIfResponseReceived() {
818830 streamingSubscriberConnection .awaitRunning ();
819831
820832 ResponseObserver <StreamingPullResponse > observer = observerCaptor .getValue ();
821- StreamController mockController = mock (StreamController .class );
833+ StreamController mockController =
834+ mock (StreamController .class , withSettings ().withoutAnnotations ());
822835 observer .onStart (mockController );
823836
824837 // t=30s: ping sent.
@@ -837,7 +850,8 @@ private StreamingSubscriberConnection getStreamingSubscriberConnection(
837850 boolean exactlyOnceDeliveryEnabled ) {
838851 StreamingSubscriberConnection streamingSubscriberConnection =
839852 getStreamingSubscriberConnectionFromBuilder (
840- StreamingSubscriberConnection .newBuilder (mock (MessageReceiverWithAckResponse .class )));
853+ StreamingSubscriberConnection .newBuilder (
854+ mock (MessageReceiverWithAckResponse .class , withSettings ().withoutAnnotations ())));
841855
842856 // This would normally be set from the streaming pull response
843857 streamingSubscriberConnection .setExactlyOnceDeliveryEnabled (exactlyOnceDeliveryEnabled );
@@ -848,7 +862,8 @@ private StreamingSubscriberConnection getStreamingSubscriberConnection(
848862 private StreamingSubscriberConnection getKeepaliveStreamingSubscriberConnection () {
849863 StreamingSubscriberConnection streamingSubscriberConnection =
850864 getStreamingSubscriberConnectionFromBuilder (
851- StreamingSubscriberConnection .newBuilder (mock (MessageReceiverWithAckResponse .class ))
865+ StreamingSubscriberConnection .newBuilder (
866+ mock (MessageReceiverWithAckResponse .class , withSettings ().withoutAnnotations ()))
852867 .setProtocolVersion (KEEP_ALIVE_SUPPORT_VERSION ));
853868
854869 return streamingSubscriberConnection ;
@@ -860,11 +875,12 @@ private StreamingSubscriberConnection getStreamingSubscriberConnectionFromBuilde
860875 .setSubscription (MOCK_SUBSCRIPTION_NAME )
861876 .setAckExpirationPadding (ACK_EXPIRATION_PADDING_DEFAULT_DURATION )
862877 .setMaxAckExtensionPeriod (MAX_ACK_EXTENSION_PERIOD )
863- .setAckLatencyDistribution (mock (Distribution .class ))
878+ .setAckLatencyDistribution (mock (Distribution .class , withSettings (). withoutAnnotations () ))
864879 .setSubscriberStub (mockSubscriberStub )
865880 .setChannelAffinity (0 )
866- .setFlowControlSettings (mock (FlowControlSettings .class ))
867- .setFlowController (mock (FlowController .class ))
881+ .setFlowControlSettings (
882+ mock (FlowControlSettings .class , withSettings ().withoutAnnotations ()))
883+ .setFlowController (mock (FlowController .class , withSettings ().withoutAnnotations ()))
868884 .setExecutor (executor )
869885 .setSystemExecutor (systemExecutor )
870886 .setClock (clock )
@@ -881,11 +897,12 @@ private StreamingSubscriberConnection getStreamingSubscriberConnectionFromBuilde
881897 return builder
882898 .setSubscription (MOCK_SUBSCRIPTION_NAME )
883899 .setAckExpirationPadding (ACK_EXPIRATION_PADDING_DEFAULT_DURATION )
884- .setAckLatencyDistribution (mock (Distribution .class ))
900+ .setAckLatencyDistribution (mock (Distribution .class , withSettings (). withoutAnnotations () ))
885901 .setSubscriberStub (mockSubscriberStub )
886902 .setChannelAffinity (0 )
887- .setFlowControlSettings (mock (FlowControlSettings .class ))
888- .setFlowController (mock (FlowController .class ))
903+ .setFlowControlSettings (
904+ mock (FlowControlSettings .class , withSettings ().withoutAnnotations ()))
905+ .setFlowController (mock (FlowController .class , withSettings ().withoutAnnotations ()))
889906 .setExecutor (executor )
890907 .setSystemExecutor (systemExecutor )
891908 .setClock (clock )
0 commit comments