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());
}
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());
}
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());
}
Aggregations