Search in sources :

Example 61 with PubsubMessage

use of com.google.pubsub.v1.PubsubMessage in project spring-cloud-gcp by spring-cloud.

the class PubSubSubscriberTemplateTests method testPullNext_NoMessages.

@Test
public void testPullNext_NoMessages() {
    when(this.pullCallable.call(any(PullRequest.class))).thenReturn(PullResponse.newBuilder().build());
    PubsubMessage message = this.pubSubSubscriberTemplate.pullNext("sub2");
    assertThat(message).isNull();
    verify(this.subscriberFactory).createPullRequest("sub2", 1, true);
    verify(this.pubSubSubscriberTemplate, never()).ack(any());
}
Also used : PullRequest(com.google.pubsub.v1.PullRequest) PubsubMessage(com.google.pubsub.v1.PubsubMessage) ConvertedAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedAcknowledgeablePubsubMessage) AcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.AcknowledgeablePubsubMessage) ConvertedBasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedBasicAcknowledgeablePubsubMessage) BasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage) Test(org.junit.Test)

Example 62 with PubsubMessage

use of com.google.pubsub.v1.PubsubMessage in project spring-cloud-gcp by spring-cloud.

the class PubSubSubscriberTemplateTests method testPullAndAckAsync.

@Test
public void testPullAndAckAsync() throws InterruptedException, ExecutionException, TimeoutException {
    ListenableFuture<List<PubsubMessage>> asyncResult = this.pubSubSubscriberTemplate.pullAndAckAsync("sub2", 1, true);
    List<PubsubMessage> result = asyncResult.get(10L, TimeUnit.SECONDS);
    assertThat(asyncResult.isDone()).isTrue();
    assertThat(result.size()).isEqualTo(1);
    PubsubMessage pubsubMessage = result.get(0);
    assertThat(pubsubMessage).isSameAs(this.pubsubMessage);
    verify(this.pubSubSubscriberTemplate, times(1)).ack(any());
}
Also used : List(java.util.List) PubsubMessage(com.google.pubsub.v1.PubsubMessage) ConvertedAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedAcknowledgeablePubsubMessage) AcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.AcknowledgeablePubsubMessage) ConvertedBasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedBasicAcknowledgeablePubsubMessage) BasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage) Test(org.junit.Test)

Example 63 with PubsubMessage

use of com.google.pubsub.v1.PubsubMessage in project spring-cloud-gcp by spring-cloud.

the class PubSubSubscriberTemplateTests method testPullNext.

@Test
public void testPullNext() {
    PubsubMessage message = this.pubSubSubscriberTemplate.pullNext("sub2");
    assertThat(message).isSameAs(this.pubsubMessage);
    verify(this.subscriberFactory).createPullRequest("sub2", 1, true);
    verify(this.pubSubSubscriberTemplate, times(1)).ack(any());
}
Also used : PubsubMessage(com.google.pubsub.v1.PubsubMessage) ConvertedAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedAcknowledgeablePubsubMessage) AcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.AcknowledgeablePubsubMessage) ConvertedBasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.converter.ConvertedBasicAcknowledgeablePubsubMessage) BasicAcknowledgeablePubsubMessage(org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage) Test(org.junit.Test)

Aggregations

PubsubMessage (com.google.pubsub.v1.PubsubMessage)51 ByteString (com.google.protobuf.ByteString)28 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)15 Subscriber (com.google.cloud.pubsub.v1.Subscriber)12 List (java.util.List)12 AcknowledgeablePubsubMessage (org.springframework.cloud.gcp.pubsub.support.AcknowledgeablePubsubMessage)12 Publisher (com.google.cloud.pubsub.v1.Publisher)11 ConvertedAcknowledgeablePubsubMessage (org.springframework.cloud.gcp.pubsub.support.converter.ConvertedAcknowledgeablePubsubMessage)11 ProjectTopicName (com.google.pubsub.v1.ProjectTopicName)10 ProjectSubscriptionName (com.google.pubsub.v1.ProjectSubscriptionName)9 BasicAcknowledgeablePubsubMessage (org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage)9 ConvertedBasicAcknowledgeablePubsubMessage (org.springframework.cloud.gcp.pubsub.support.converter.ConvertedBasicAcknowledgeablePubsubMessage)9 SettableApiFuture (com.google.api.core.SettableApiFuture)8 ServiceOptions (com.google.cloud.ServiceOptions)8 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)8 Action (com.google.privacy.dlp.v2.Action)8 BigQueryTable (com.google.privacy.dlp.v2.BigQueryTable)8 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)8 DlpJob (com.google.privacy.dlp.v2.DlpJob)8