Skip to content

Commit

Permalink
Regenerate pubsub with resource names (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbausor authored and garrettjonesgoogle committed Nov 18, 2016
1 parent 628b7c9 commit 3f3e7c0
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 276 deletions.
4 changes: 2 additions & 2 deletions google-cloud-pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-pubsub-v1</artifactId>
<version>0.1.0</version>
<artifactId>grpc-google-cloud-pubsub-v1</artifactId>
<version>0.1.3</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import com.google.api.gax.grpc.PagedListDescriptor;
import com.google.api.gax.grpc.PagedListResponseImpl;
import com.google.api.gax.grpc.UnaryCallable;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.pubsub.v1.ListSubscriptionsRequest;
import com.google.pubsub.v1.ListSubscriptionsResponse;
import com.google.pubsub.v1.ListTopicSubscriptionsRequest;
import com.google.pubsub.v1.ListTopicSubscriptionsResponse;
import com.google.pubsub.v1.ListTopicsRequest;
import com.google.pubsub.v1.ListTopicsResponse;
import com.google.pubsub.v1.Subscription;
import com.google.pubsub.v1.SubscriptionName;
import com.google.pubsub.v1.Topic;

// AUTO-GENERATED DOCUMENTATION AND CLASS
Expand Down Expand Up @@ -61,6 +64,17 @@ public ListTopicSubscriptionsPagedResponse(
CallContext context) {
super(callable, pageDescriptor, request, context);
}

public Iterable<SubscriptionName> iterateAllAsSubscriptionName() {
return Iterables.transform(
iterateAllElements(),
new Function<String, SubscriptionName>() {
@Override
public SubscriptionName apply(String arg0) {
return SubscriptionName.parse(arg0);
}
});
}
}

public static class ListSubscriptionsPagedResponse
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* <pre>
* <code>
* try (PublisherApi publisherApi = PublisherApi.create()) {
* String formattedName = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
* Topic response = publisherApi.createTopic(formattedName);
* TopicName name = TopicName.create("[PROJECT]", "[TOPIC]");
* Topic response = publisherApi.createTopic(name);
* }
* </code>
* </pre>
Expand All @@ -45,11 +45,11 @@
* <pre>
* <code>
* try (SubscriberApi subscriberApi = SubscriberApi.create()) {
* String formattedName = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
* String formattedTopic = SubscriberApi.formatTopicName("[PROJECT]", "[TOPIC]");
* SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
* TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
* PushConfig pushConfig = PushConfig.newBuilder().build();
* int ackDeadlineSeconds = 0;
* Subscription response = subscriberApi.createSubscription(formattedName, formattedTopic, pushConfig, ackDeadlineSeconds);
* Subscription response = subscriberApi.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
* }
* </code>
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void addException(Exception exception) {
serviceImpl.addException(exception);
}

@Override
public void setResponses(List<GeneratedMessageV3> responses) {
serviceImpl.setResponses(responses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void addException(Exception exception) {
serviceImpl.addException(exception);
}

@Override
public void setResponses(List<GeneratedMessageV3> responses) {
serviceImpl.setResponses(responses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void addException(Exception exception) {
serviceImpl.addException(exception);
}

@Override
public void setResponses(List<GeneratedMessageV3> responses) {
serviceImpl.setResponses(responses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.google.pubsub.v1.PullResponse;
import com.google.pubsub.v1.PushConfig;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.ProjectName;
import com.google.pubsub.v1.TopicName;
import com.google.pubsub.v1.SubscriptionName;

import io.grpc.ManagedChannel;

Expand Down Expand Up @@ -106,18 +109,17 @@ public void tearDown() throws Exception {

@Test
public void testCreateTopic() throws Exception {
String topicName = PublisherApi.formatTopicName("my-project", "my-topic");
TopicName topicName = TopicName.create("my-project", "my-topic");
Topic result = publisherApi.createTopic(topicName);
Assert.assertEquals(topicName, result.getName());
Assert.assertEquals(topicName, result.getNameAsTopicName());
}

@Test
public void testPublish() throws Exception {
String topicName = PublisherApi.formatTopicName("my-project", "publish-topic");
TopicName topicName = TopicName.create("my-project", "my-topic");
publisherApi.createTopic(topicName);

String subscriberName =
SubscriberApi.formatSubscriptionName("my-project", "my-subscribe");
SubscriptionName subscriberName = SubscriptionName.create("my-project", "my-subscribe");
PushConfig config = PushConfig.getDefaultInstance();
subscriberApi.createSubscription(subscriberName, topicName, config, 5);

Expand All @@ -133,11 +135,10 @@ public void testPublish() throws Exception {

@Test
public void testBundledPublish() throws Exception {
String topicName = PublisherApi.formatTopicName("my-project", "publish-topic");
TopicName topicName = TopicName.create("my-project", "my-topic");
bundledPublisherApi.createTopic(topicName);

String subscriberName =
SubscriberApi.formatSubscriptionName("my-project", "my-subscribe");
SubscriptionName subscriberName = SubscriptionName.create("my-project", "my-subscribe");
PushConfig config = PushConfig.getDefaultInstance();
subscriberApi.createSubscription(subscriberName, topicName, config, 5);

Expand All @@ -154,19 +155,19 @@ public void testBundledPublish() throws Exception {

@Test
public void testGetTopic() throws Exception {
String topicName = PublisherApi.formatTopicName("my-project", "fun-topic");
TopicName topicName = TopicName.create("my-project", "my-topic");
publisherApi.createTopic(topicName);
Topic result = publisherApi.getTopic(topicName);
Assert.assertNotNull(result);
Assert.assertEquals(topicName, result.getName());
Assert.assertEquals(topicName, result.getNameAsTopicName());
}

@Test
public void testListTopics() throws Exception {
String project1 = PublisherApi.formatProjectName("project.1");
String topicName1 = PublisherApi.formatTopicName("project.1", "topic.1");
String topicName2 = PublisherApi.formatTopicName("project.1", "topic.2");
String topicName3 = PublisherApi.formatTopicName("project.2", "topic.3");
ProjectName project1 = ProjectName.create("project.1");
TopicName topicName1 = TopicName.create("project.1", "topic.1");
TopicName topicName2 = TopicName.create("project.1", "topic.2");
TopicName topicName3 = TopicName.create("project.2", "topic.3");
publisherApi.createTopic(topicName1);
publisherApi.createTopic(topicName2);
publisherApi.createTopic(topicName3);
Expand All @@ -175,14 +176,14 @@ public void testListTopics() throws Exception {
topics.add(topic);
}
Assert.assertEquals(2, topics.size());
Assert.assertEquals(topicName1, topics.get(0).getName());
Assert.assertEquals(topicName2, topics.get(1).getName());
Assert.assertEquals(topicName1, topics.get(0).getNameAsTopicName());
Assert.assertEquals(topicName2, topics.get(1).getNameAsTopicName());
}

@Test
public void testDeleteTopic() throws Exception {
String project = PublisherApi.formatProjectName("project.1");
String topicName = PublisherApi.formatTopicName("my-project", "fun-topic");
ProjectName project = ProjectName.create("project.1");
TopicName topicName = TopicName.create("my-project", "my-topic");
publisherApi.createTopic(topicName);
publisherApi.deleteTopic(topicName);
List<Topic> topics = new ArrayList<>();
Expand Down
Loading

0 comments on commit 3f3e7c0

Please sign in to comment.