@@ -289,6 +289,15 @@ public void testInitialize() throws Exception {
289
289
assertTrue (remoteRequestInitializer .isCalled );
290
290
}
291
291
292
+ @ Test
293
+ public void testParseServiceName_nonMtlsRootUrl () {
294
+ AbstractGoogleClient .Builder clientBuilder =
295
+ new MockGoogleClient .Builder (
296
+ TRANSPORT , "https://random.googleapis.com/" , "" , JSON_OBJECT_PARSER , null )
297
+ .setApplicationName ("Test Application" );
298
+ assertEquals (clientBuilder .getServiceName (), "random" );
299
+ }
300
+
292
301
@ Test
293
302
public void testParseServiceName_mtlsRootUrl () {
294
303
AbstractGoogleClient .Builder clientBuilder =
@@ -299,21 +308,52 @@ public void testParseServiceName_mtlsRootUrl() {
299
308
}
300
309
301
310
@ Test
302
- public void testParseServiceName_nonMtlsRootUrl () {
311
+ public void testParseServiceName_nonGDURootUrl () {
312
+ AbstractGoogleClient .Builder clientBuilder =
313
+ new MockGoogleClient .Builder (
314
+ TRANSPORT , "https://test.random.com/" , "" , JSON_OBJECT_PARSER , null )
315
+ .setApplicationName ("Test Application" );
316
+ assertNull (clientBuilder .getServiceName ());
317
+ }
318
+
319
+ @ Test
320
+ public void testIsUserSetEndpoint_nonMtlsRootUrl () {
303
321
AbstractGoogleClient .Builder clientBuilder =
304
322
new MockGoogleClient .Builder (
305
323
TRANSPORT , "https://random.googleapis.com/" , "" , JSON_OBJECT_PARSER , null )
306
324
.setApplicationName ("Test Application" );
307
- assertEquals (clientBuilder .getServiceName (), "random" );
325
+ assertFalse (clientBuilder .isUserConfiguredEndpoint );
308
326
}
309
327
310
328
@ Test
311
- public void testParseServiceName_nonGDURootUrl () {
329
+ public void testIsUserSetEndpoint_mtlsRootUrl () {
330
+ AbstractGoogleClient .Builder clientBuilder =
331
+ new MockGoogleClient .Builder (
332
+ TRANSPORT , "https://test.mtls.googleapis.com/" , "" , JSON_OBJECT_PARSER , null )
333
+ .setApplicationName ("Test Application" );
334
+ assertFalse (clientBuilder .isUserConfiguredEndpoint );
335
+ }
336
+
337
+ @ Test
338
+ public void testIsUserSetEndpoint_nonGDURootUrl () {
312
339
AbstractGoogleClient .Builder clientBuilder =
313
340
new MockGoogleClient .Builder (
314
341
TRANSPORT , "https://test.random.com/" , "" , JSON_OBJECT_PARSER , null )
315
342
.setApplicationName ("Test Application" );
316
- assertNull (clientBuilder .getServiceName ());
343
+ assertTrue (clientBuilder .isUserConfiguredEndpoint );
344
+ }
345
+
346
+ @ Test
347
+ public void testIsUserSetEndpoint_regionalEndpoint () {
348
+ AbstractGoogleClient .Builder clientBuilder =
349
+ new MockGoogleClient .Builder (
350
+ TRANSPORT ,
351
+ "https://us-east-4.coolservice.googleapis.com/" ,
352
+ "" ,
353
+ JSON_OBJECT_PARSER ,
354
+ null )
355
+ .setApplicationName ("Test Application" );
356
+ assertTrue (clientBuilder .isUserConfiguredEndpoint );
317
357
}
318
358
319
359
@ Test
0 commit comments