2222import com .google .pubsub .v1 .PullResponse ;
2323import com .google .pubsub .v1 .PushConfig ;
2424import com .google .pubsub .v1 .Topic ;
25+ import com .google .pubsub .v1 .ProjectName ;
26+ import com .google .pubsub .v1 .TopicName ;
27+ import com .google .pubsub .v1 .SubscriptionName ;
2528
2629import io .grpc .ManagedChannel ;
2730
@@ -106,18 +109,17 @@ public void tearDown() throws Exception {
106109
107110 @ Test
108111 public void testCreateTopic () throws Exception {
109- String topicName = PublisherApi . formatTopicName ("my-project" , "my-topic" );
112+ TopicName topicName = TopicName . create ("my-project" , "my-topic" );
110113 Topic result = publisherApi .createTopic (topicName );
111- Assert .assertEquals (topicName , result .getName ());
114+ Assert .assertEquals (topicName , result .getNameAsTopicName ());
112115 }
113116
114117 @ Test
115118 public void testPublish () throws Exception {
116- String topicName = PublisherApi . formatTopicName ("my-project" , "publish -topic" );
119+ TopicName topicName = TopicName . create ("my-project" , "my -topic" );
117120 publisherApi .createTopic (topicName );
118121
119- String subscriberName =
120- SubscriberApi .formatSubscriptionName ("my-project" , "my-subscribe" );
122+ SubscriptionName subscriberName = SubscriptionName .create ("my-project" , "my-subscribe" );
121123 PushConfig config = PushConfig .getDefaultInstance ();
122124 subscriberApi .createSubscription (subscriberName , topicName , config , 5 );
123125
@@ -133,11 +135,10 @@ public void testPublish() throws Exception {
133135
134136 @ Test
135137 public void testBundledPublish () throws Exception {
136- String topicName = PublisherApi . formatTopicName ("my-project" , "publish -topic" );
138+ TopicName topicName = TopicName . create ("my-project" , "my -topic" );
137139 bundledPublisherApi .createTopic (topicName );
138140
139- String subscriberName =
140- SubscriberApi .formatSubscriptionName ("my-project" , "my-subscribe" );
141+ SubscriptionName subscriberName = SubscriptionName .create ("my-project" , "my-subscribe" );
141142 PushConfig config = PushConfig .getDefaultInstance ();
142143 subscriberApi .createSubscription (subscriberName , topicName , config , 5 );
143144
@@ -154,19 +155,19 @@ public void testBundledPublish() throws Exception {
154155
155156 @ Test
156157 public void testGetTopic () throws Exception {
157- String topicName = PublisherApi . formatTopicName ("my-project" , "fun -topic" );
158+ TopicName topicName = TopicName . create ("my-project" , "my -topic" );
158159 publisherApi .createTopic (topicName );
159160 Topic result = publisherApi .getTopic (topicName );
160161 Assert .assertNotNull (result );
161- Assert .assertEquals (topicName , result .getName ());
162+ Assert .assertEquals (topicName , result .getNameAsTopicName ());
162163 }
163164
164165 @ Test
165166 public void testListTopics () throws Exception {
166- String project1 = PublisherApi . formatProjectName ("project.1" );
167- String topicName1 = PublisherApi . formatTopicName ("project.1" , "topic.1" );
168- String topicName2 = PublisherApi . formatTopicName ("project.1" , "topic.2" );
169- String topicName3 = PublisherApi . formatTopicName ("project.2" , "topic.3" );
167+ ProjectName project1 = ProjectName . create ("project.1" );
168+ TopicName topicName1 = TopicName . create ("project.1" , "topic.1" );
169+ TopicName topicName2 = TopicName . create ("project.1" , "topic.2" );
170+ TopicName topicName3 = TopicName . create ("project.2" , "topic.3" );
170171 publisherApi .createTopic (topicName1 );
171172 publisherApi .createTopic (topicName2 );
172173 publisherApi .createTopic (topicName3 );
@@ -175,14 +176,14 @@ public void testListTopics() throws Exception {
175176 topics .add (topic );
176177 }
177178 Assert .assertEquals (2 , topics .size ());
178- Assert .assertEquals (topicName1 , topics .get (0 ).getName ());
179- Assert .assertEquals (topicName2 , topics .get (1 ).getName ());
179+ Assert .assertEquals (topicName1 , topics .get (0 ).getNameAsTopicName ());
180+ Assert .assertEquals (topicName2 , topics .get (1 ).getNameAsTopicName ());
180181 }
181182
182183 @ Test
183184 public void testDeleteTopic () throws Exception {
184- String project = PublisherApi . formatProjectName ("project.1" );
185- String topicName = PublisherApi . formatTopicName ("my-project" , "fun -topic" );
185+ ProjectName project = ProjectName . create ("project.1" );
186+ TopicName topicName = TopicName . create ("my-project" , "my -topic" );
186187 publisherApi .createTopic (topicName );
187188 publisherApi .deleteTopic (topicName );
188189 List <Topic > topics = new ArrayList <>();
0 commit comments