EndpointBuilder { public static String createEndpoint( @NonNull Service service, @NonNull String regionId, @NonNull Realm realm) { final String endpointTemplateToUse; if (StringUtils.isNotBlank(service.getServiceEndpointTemplate())) { endpointTemplateToUse = service.getServiceEndpointTemplate(); } else { endpointTemplateToUse = DEFAULT_ENDPOINT_TEMPLATE; } final String regionIdToUse; synchronized (OVERRIDE_REGION_IDS) { regionIdToUse = OVERRIDE_REGION_IDS.getOrDefault(regionId, regionId); } return DefaultEndpointConfiguration.builder(endpointTemplateToUse) .regionId(regionIdToUse) .serviceEndpointPrefix(service.getServiceEndpointPrefix()) .secondLevelDomain(realm.getSecondLevelDomain()) .build(); }  static String createEndpoint(
            @NonNull Service service, @NonNull String regionId, @NonNull Realm realm); static String createEndpoint(@NonNull Service service, @NonNull Region region); static void overrideRegionId(
            @NonNull String regionId, @NonNull String overrideRegionId); static final String DEFAULT_ENDPOINT_TEMPLATE; }
@Test public void createEndpoint_useDefaultTemplate() { Service testService = Services.serviceBuilder() .serviceEndpointPrefix("foobar") .serviceName("EndpointBuilderTest1") .build(); assertEquals( "https: EndpointBuilder.createEndpoint(testService, Region.US_PHOENIX_1)); }
@Test public void createEndpoint_useCustomTemplate() { Service testService = Services.serviceBuilder() .serviceEndpointPrefix("foobar") .serviceName("EndpointBuilderTest2") .serviceEndpointTemplate("https: .build(); assertEquals( "https: EndpointBuilder.createEndpoint(testService, Region.US_PHOENIX_1)); }
@Test public void createEndpoint_useCustomTemplate_allTemplatesUsed() { Service testService = Services.serviceBuilder() .serviceEndpointPrefix("foobar") .serviceName("EndpointBuilderTest3") .serviceEndpointTemplate( "http: .build(); assertEquals( "http: EndpointBuilder.createEndpoint(testService, Region.US_PHOENIX_1)); }