public class PubsubTestClient extends PubsubClient implements java.io.Serializable
PubsubClient for use by unit tests. Only suitable for
 testing publish(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.TopicPath, java.util.List<org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.OutgoingMessage>), pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean), acknowledge(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, java.util.List<java.lang.String>) and modifyAckDeadline(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, java.util.List<java.lang.String>, int)
 methods. Relies on statics to mimic the Pubsub service, though we try to hide that.| Modifier and Type | Class and Description | 
|---|---|
| static interface  | PubsubTestClient.PubsubTestClientFactoryClosing the factory will validate all expected messages were processed. | 
PubsubClient.IncomingMessage, PubsubClient.OutgoingMessage, PubsubClient.ProjectPath, PubsubClient.PubsubClientFactory, PubsubClient.SchemaPath, PubsubClient.SubscriptionPath, PubsubClient.TopicPath| Constructor and Description | 
|---|
| PubsubTestClient() | 
| Modifier and Type | Method and Description | 
|---|---|
| int | ackDeadlineSeconds(PubsubClient.SubscriptionPath subscription)Return the ack deadline, in seconds, for  subscription. | 
| void | acknowledge(PubsubClient.SubscriptionPath subscription,
           java.util.List<java.lang.String> ackIds)Acknowldege messages from  subscriptionwithackIds. | 
| void | advance()For subscription mode only: Track progression of time according to the  Clockpassed . | 
| void | close() | 
| static PubsubTestClient.PubsubTestClientFactory | createFactoryForCreateSubscription() | 
| static PubsubTestClient.PubsubTestClientFactory | createFactoryForGetSchema(PubsubClient.TopicPath expectedTopic,
                         @Nullable PubsubClient.SchemaPath expectedSchemaPath,
                         @Nullable Schema expectedSchema) | 
| static PubsubTestClient.PubsubTestClientFactory | createFactoryForPublish(@Nullable PubsubClient.TopicPath expectedTopic,
                       java.lang.Iterable<PubsubClient.OutgoingMessage> expectedOutgoingMessages,
                       java.lang.Iterable<PubsubClient.OutgoingMessage> failingOutgoingMessages)Return a factory for testing publishers. | 
| static PubsubTestClient.PubsubTestClientFactory | createFactoryForPull(com.google.api.client.util.Clock clock,
                    PubsubClient.SubscriptionPath expectedSubscription,
                    int ackTimeoutSec,
                    java.lang.Iterable<PubsubClient.IncomingMessage> expectedIncomingMessages)Return a factory for testing subscribers. | 
| static PubsubTestClient.PubsubTestClientFactory | createFactoryForPullAndPublish(PubsubClient.SubscriptionPath pullSubscription,
                              PubsubClient.TopicPath publishTopicPath,
                              com.google.api.client.util.Clock pullClock,
                              int pullAckTimeoutSec,
                              java.lang.Iterable<PubsubClient.IncomingMessage> expectedIncomingMessages,
                              java.lang.Iterable<PubsubClient.OutgoingMessage> expectedOutgoingMessages,
                              java.lang.Iterable<PubsubClient.OutgoingMessage> failingOutgoingMessages)Returns a factory for a test that is expected to both publish and pull messages over the course
 of the test. | 
| void | createSchema(PubsubClient.SchemaPath schemaPath,
            java.lang.String schemaContent,
            com.google.pubsub.v1.Schema.Type type)Create  Schemafrom Schema definition content. | 
| void | createSubscription(PubsubClient.TopicPath topic,
                  PubsubClient.SubscriptionPath subscription,
                  int ackDeadlineSeconds)Create  subscriptiontotopic. | 
| void | createTopic(PubsubClient.TopicPath topic)Create  topic. | 
| void | createTopic(PubsubClient.TopicPath topic,
           PubsubClient.SchemaPath schema)Create {link TopicPath} with  PubsubClient.SchemaPath. | 
| void | deleteSchema(PubsubClient.SchemaPath schemaPath)Delete  SchemaPath. | 
| void | deleteSubscription(PubsubClient.SubscriptionPath subscription)Delete  subscription. | 
| void | deleteTopic(PubsubClient.TopicPath topic) | 
| Schema | getSchema(PubsubClient.SchemaPath schemaPath)Return a Beam  Schemafrom the Pub/Sub schema resource, if exists. | 
| PubsubClient.SchemaPath | getSchemaPath(PubsubClient.TopicPath topicPath)Return  PubsubClient.SchemaPathfromPubsubClient.TopicPathif exists. | 
| boolean | isEOF()Return true if  PubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean)will always return empty list. | 
| boolean | isTopicExists(PubsubClient.TopicPath topic)Return true if  topicexists. | 
| java.util.List<PubsubClient.SubscriptionPath> | listSubscriptions(PubsubClient.ProjectPath project,
                 PubsubClient.TopicPath topic)Return a list of subscriptions for  topicinproject. | 
| java.util.List<PubsubClient.TopicPath> | listTopics(PubsubClient.ProjectPath project)Return a list of topics for  project. | 
| void | modifyAckDeadline(PubsubClient.SubscriptionPath subscription,
                 java.util.List<java.lang.String> ackIds,
                 int deadlineSeconds)Modify the ack deadline for messages from  subscriptionwithackIdsto bedeadlineSecondsfrom now. | 
| int | publish(PubsubClient.TopicPath topic,
       java.util.List<PubsubClient.OutgoingMessage> outgoingMessages)Publish  outgoingMessagesto Pubsubtopic. | 
| java.util.List<PubsubClient.IncomingMessage> | pull(long requestTimeMsSinceEpoch,
    PubsubClient.SubscriptionPath subscription,
    int batchSize,
    boolean returnImmediately)Request the next batch of up to  batchSizemessages fromsubscription. | 
createRandomSubscription, extractTimestampAttribute, parseTimestampAsMsSinceEpoch, projectPathFromId, projectPathFromPath, schemaPathFromId, schemaPathFromPath, subscriptionPathFromName, subscriptionPathFromPath, topicPathFromName, topicPathFromPathpublic static PubsubTestClient.PubsubTestClientFactory createFactoryForPublish(@Nullable PubsubClient.TopicPath expectedTopic, java.lang.Iterable<PubsubClient.OutgoingMessage> expectedOutgoingMessages, java.lang.Iterable<PubsubClient.OutgoingMessage> failingOutgoingMessages)
public static PubsubTestClient.PubsubTestClientFactory createFactoryForPull(com.google.api.client.util.Clock clock, PubsubClient.SubscriptionPath expectedSubscription, int ackTimeoutSec, java.lang.Iterable<PubsubClient.IncomingMessage> expectedIncomingMessages)
public static PubsubTestClient.PubsubTestClientFactory createFactoryForPullAndPublish(PubsubClient.SubscriptionPath pullSubscription, PubsubClient.TopicPath publishTopicPath, com.google.api.client.util.Clock pullClock, int pullAckTimeoutSec, java.lang.Iterable<PubsubClient.IncomingMessage> expectedIncomingMessages, java.lang.Iterable<PubsubClient.OutgoingMessage> expectedOutgoingMessages, java.lang.Iterable<PubsubClient.OutgoingMessage> failingOutgoingMessages)
public static PubsubTestClient.PubsubTestClientFactory createFactoryForGetSchema(PubsubClient.TopicPath expectedTopic, @Nullable PubsubClient.SchemaPath expectedSchemaPath, @Nullable Schema expectedSchema)
public static PubsubTestClient.PubsubTestClientFactory createFactoryForCreateSubscription()
public void advance()
Clock passed .
 This will simulate Pubsub expiring outstanding ACKs.public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic int publish(PubsubClient.TopicPath topic, java.util.List<PubsubClient.OutgoingMessage> outgoingMessages) throws java.io.IOException
PubsubClientoutgoingMessages to Pubsub topic. Return number of messages published.publish in class PubsubClientjava.io.IOExceptionpublic java.util.List<PubsubClient.IncomingMessage> pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) throws java.io.IOException
PubsubClientbatchSize messages from subscription. Return
 the received messages, or empty collection if none were available. Does not wait for messages
 to arrive if returnImmediately is true. Returned messages will record their
 request time as requestTimeMsSinceEpoch.pull in class PubsubClientjava.io.IOExceptionpublic void acknowledge(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds) throws java.io.IOException
PubsubClientsubscription with ackIds.acknowledge in class PubsubClientjava.io.IOExceptionpublic void modifyAckDeadline(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds, int deadlineSeconds) throws java.io.IOException
PubsubClientsubscription with ackIds to be deadlineSeconds from now.modifyAckDeadline in class PubsubClientjava.io.IOExceptionpublic void createTopic(PubsubClient.TopicPath topic) throws java.io.IOException
PubsubClienttopic.createTopic in class PubsubClientjava.io.IOExceptionpublic void createTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) throws java.io.IOException
PubsubClientPubsubClient.SchemaPath.createTopic in class PubsubClientjava.io.IOExceptionpublic void deleteTopic(PubsubClient.TopicPath topic) throws java.io.IOException
deleteTopic in class PubsubClientjava.io.IOExceptionpublic java.util.List<PubsubClient.TopicPath> listTopics(PubsubClient.ProjectPath project) throws java.io.IOException
PubsubClientproject.listTopics in class PubsubClientjava.io.IOExceptionpublic boolean isTopicExists(PubsubClient.TopicPath topic) throws java.io.IOException
PubsubClienttopic exists.isTopicExists in class PubsubClientjava.io.IOExceptionpublic void createSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) throws java.io.IOException
PubsubClientsubscription to topic.createSubscription in class PubsubClientjava.io.IOExceptionpublic void deleteSubscription(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
PubsubClientsubscription.deleteSubscription in class PubsubClientjava.io.IOExceptionpublic java.util.List<PubsubClient.SubscriptionPath> listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) throws java.io.IOException
PubsubClienttopic in project.listSubscriptions in class PubsubClientjava.io.IOExceptionpublic int ackDeadlineSeconds(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
PubsubClientsubscription.ackDeadlineSeconds in class PubsubClientjava.io.IOExceptionpublic boolean isEOF()
PubsubClientPubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean) will always return empty list. Actual clients will
 return false. Test clients may return true to signal that all expected
 messages have been pulled and the test may complete.isEOF in class PubsubClientpublic void createSchema(PubsubClient.SchemaPath schemaPath, java.lang.String schemaContent, com.google.pubsub.v1.Schema.Type type) throws java.io.IOException
PubsubClientSchema from Schema definition content.createSchema in class PubsubClientjava.io.IOExceptionpublic void deleteSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
SchemaPath.deleteSchema in class PubsubClientjava.io.IOExceptionpublic PubsubClient.SchemaPath getSchemaPath(PubsubClient.TopicPath topicPath) throws java.io.IOException
PubsubClientPubsubClient.SchemaPath from PubsubClient.TopicPath if exists.getSchemaPath in class PubsubClientjava.io.IOExceptionpublic Schema getSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
PubsubClientSchema from the Pub/Sub schema resource, if exists.getSchema in class PubsubClientjava.io.IOException