This is an automated email from the ASF dual-hosted git repository.
ibzib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new c56c33b listSubscription should remove TestPubsub's own sub
new 412db21 Merge pull request #13281 from TheNeuralBit/beam-11159-fix
c56c33b is described below
commit c56c33b2f5fc042c57776e9b07c7bce7650be8e4
Author: Brian Hulette <[email protected]>
AuthorDate: Fri Nov 6 16:02:50 2020 -0800
listSubscription should remove TestPubsub's own sub
---
.../main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java
index 8df0004..2c32c55 100644
---
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java
+++
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java
@@ -47,6 +47,7 @@ import org.apache.beam.sdk.testing.TestPipeline;
import org.apache.beam.sdk.testing.TestPipelineOptions;
import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterables;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Streams;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hamcrest.Matcher;
import org.joda.time.DateTime;
@@ -227,9 +228,12 @@ public class TestPubsub implements TestRule {
return subscriptionPath;
}
- private Iterable<String> listSubscriptions(TopicPath topicPath) {
+ private List<String> listSubscriptions(TopicPath topicPath) {
Preconditions.checkNotNull(topicAdmin);
- return topicAdmin.listTopicSubscriptions(topicPath.getPath()).iterateAll();
+ // Exclude subscriptionPath, the subscription that we created
+ return
Streams.stream(topicAdmin.listTopicSubscriptions(topicPath.getPath()).iterateAll())
+ .filter((path) -> !path.equals(subscriptionPath.getPath()))
+ .collect(Collectors.toList());
}
/** Publish messages to {@link #topicPath()}. */