@@ -847,6 +847,84 @@ public void pullTest() throws Exception {
847847 PullResponse .newBuilder ().addAllReceivedMessages (new ArrayList <ReceivedMessage >()).build ();
848848 mockSubscriber .addResponse (expectedResponse );
849849
850+ SubscriptionName subscription = SubscriptionName .of ("[PROJECT]" , "[SUBSCRIPTION]" );
851+ int maxMessages = 496131527 ;
852+
853+ PullResponse actualResponse = client .pull (subscription , maxMessages );
854+ Assert .assertEquals (expectedResponse , actualResponse );
855+
856+ List <AbstractMessage > actualRequests = mockSubscriber .getRequests ();
857+ Assert .assertEquals (1 , actualRequests .size ());
858+ PullRequest actualRequest = ((PullRequest ) actualRequests .get (0 ));
859+
860+ Assert .assertEquals (subscription .toString (), actualRequest .getSubscription ());
861+ Assert .assertEquals (maxMessages , actualRequest .getMaxMessages ());
862+ Assert .assertTrue (
863+ channelProvider .isHeaderSent (
864+ ApiClientHeaderProvider .getDefaultApiClientHeaderKey (),
865+ GaxGrpcProperties .getDefaultApiClientHeaderPattern ()));
866+ }
867+
868+ @ Test
869+ public void pullExceptionTest () throws Exception {
870+ StatusRuntimeException exception = new StatusRuntimeException (io .grpc .Status .INVALID_ARGUMENT );
871+ mockSubscriber .addException (exception );
872+
873+ try {
874+ SubscriptionName subscription = SubscriptionName .of ("[PROJECT]" , "[SUBSCRIPTION]" );
875+ int maxMessages = 496131527 ;
876+ client .pull (subscription , maxMessages );
877+ Assert .fail ("No exception raised" );
878+ } catch (InvalidArgumentException e ) {
879+ // Expected exception.
880+ }
881+ }
882+
883+ @ Test
884+ public void pullTest2 () throws Exception {
885+ PullResponse expectedResponse =
886+ PullResponse .newBuilder ().addAllReceivedMessages (new ArrayList <ReceivedMessage >()).build ();
887+ mockSubscriber .addResponse (expectedResponse );
888+
889+ String subscription = "subscription341203229" ;
890+ int maxMessages = 496131527 ;
891+
892+ PullResponse actualResponse = client .pull (subscription , maxMessages );
893+ Assert .assertEquals (expectedResponse , actualResponse );
894+
895+ List <AbstractMessage > actualRequests = mockSubscriber .getRequests ();
896+ Assert .assertEquals (1 , actualRequests .size ());
897+ PullRequest actualRequest = ((PullRequest ) actualRequests .get (0 ));
898+
899+ Assert .assertEquals (subscription , actualRequest .getSubscription ());
900+ Assert .assertEquals (maxMessages , actualRequest .getMaxMessages ());
901+ Assert .assertTrue (
902+ channelProvider .isHeaderSent (
903+ ApiClientHeaderProvider .getDefaultApiClientHeaderKey (),
904+ GaxGrpcProperties .getDefaultApiClientHeaderPattern ()));
905+ }
906+
907+ @ Test
908+ public void pullExceptionTest2 () throws Exception {
909+ StatusRuntimeException exception = new StatusRuntimeException (io .grpc .Status .INVALID_ARGUMENT );
910+ mockSubscriber .addException (exception );
911+
912+ try {
913+ String subscription = "subscription341203229" ;
914+ int maxMessages = 496131527 ;
915+ client .pull (subscription , maxMessages );
916+ Assert .fail ("No exception raised" );
917+ } catch (InvalidArgumentException e ) {
918+ // Expected exception.
919+ }
920+ }
921+
922+ @ Test
923+ public void pullTest3 () throws Exception {
924+ PullResponse expectedResponse =
925+ PullResponse .newBuilder ().addAllReceivedMessages (new ArrayList <ReceivedMessage >()).build ();
926+ mockSubscriber .addResponse (expectedResponse );
927+
850928 SubscriptionName subscription = SubscriptionName .of ("[PROJECT]" , "[SUBSCRIPTION]" );
851929 boolean returnImmediately = true ;
852930 int maxMessages = 496131527 ;
@@ -868,7 +946,7 @@ public void pullTest() throws Exception {
868946 }
869947
870948 @ Test
871- public void pullExceptionTest () throws Exception {
949+ public void pullExceptionTest3 () throws Exception {
872950 StatusRuntimeException exception = new StatusRuntimeException (io .grpc .Status .INVALID_ARGUMENT );
873951 mockSubscriber .addException (exception );
874952
@@ -884,7 +962,7 @@ public void pullExceptionTest() throws Exception {
884962 }
885963
886964 @ Test
887- public void pullTest2 () throws Exception {
965+ public void pullTest4 () throws Exception {
888966 PullResponse expectedResponse =
889967 PullResponse .newBuilder ().addAllReceivedMessages (new ArrayList <ReceivedMessage >()).build ();
890968 mockSubscriber .addResponse (expectedResponse );
@@ -910,7 +988,7 @@ public void pullTest2() throws Exception {
910988 }
911989
912990 @ Test
913- public void pullExceptionTest2 () throws Exception {
991+ public void pullExceptionTest4 () throws Exception {
914992 StatusRuntimeException exception = new StatusRuntimeException (io .grpc .Status .INVALID_ARGUMENT );
915993 mockSubscriber .addException (exception );
916994
@@ -930,6 +1008,8 @@ public void streamingPullTest() throws Exception {
9301008 StreamingPullResponse expectedResponse =
9311009 StreamingPullResponse .newBuilder ()
9321010 .addAllReceivedMessages (new ArrayList <ReceivedMessage >())
1011+ .setSubscriptionProperties (
1012+ StreamingPullResponse .SubscriptionProperties .newBuilder ().build ())
9331013 .build ();
9341014 mockSubscriber .addResponse (expectedResponse );
9351015 StreamingPullRequest request =
0 commit comments