@Test
public void noSubscriptionSplitGeneratesSubscription() throws Exception {
TopicPath topicPath = PubsubClient.topicPathFromName("my_project", "my_topic");
factory = PubsubTestClient.createFactoryForCreateSubscription();
PubsubUnboundedSource source =
new PubsubUnboundedSource(
factory,
StaticValueProvider.of(PubsubClient.projectPathFromId("my_project")),
StaticValueProvider.of(topicPath),
null ,
null ,
null ,
false );
assertThat(source.getSubscription(), nullValue());
assertThat(source.getSubscription(), nullValue());
PipelineOptions options = PipelineOptionsFactory.create();
List<PubsubSource> splits = (new PubsubSource(source)).split(3, options);
assertThat(splits, hasSize(greaterThan(0)));
for (PubsubSource split : splits) {
assertThat(split, equalTo(splits.get(0)));
}
assertThat(splits.get(0).subscriptionPath, not(nullValue()));
}