1313import org .robolectric .annotation .Config ;
1414
1515import java .util .Date ;
16+ import java .util .HashMap ;
1617import java .util .LinkedHashMap ;
18+ import java .util .Map ;
1719
1820import static org .junit .Assert .*;
1921
@@ -360,7 +362,7 @@ public void testStackWithCustomConfig() throws Exception {
360362 @ Test
361363 public void testStackWithDifferentRegions () throws Exception {
362364 com .contentstack .sdk .Config .ContentstackRegion [] regions = com .contentstack .sdk .Config .ContentstackRegion .values ();
363-
365+
364366 for (com .contentstack .sdk .Config .ContentstackRegion region : regions ) {
365367 com .contentstack .sdk .Config config = new com .contentstack .sdk .Config ();
366368 config .setRegion (region );
@@ -369,6 +371,36 @@ public void testStackWithDifferentRegions() throws Exception {
369371 }
370372 }
371373
374+ @ Test
375+ public void testAzureNaRegionSetsCorrectURL () throws Exception {
376+ com .contentstack .sdk .Config config = new com .contentstack .sdk .Config ();
377+ config .setRegion (com .contentstack .sdk .Config .ContentstackRegion .AZURE_NA );
378+ Stack regionalStack = Contentstack .stack (mockContext , "api_key" , "token" , "env" , config );
379+ assertEquals ("azure-na-cdn.contentstack.com" , regionalStack .URL );
380+ }
381+
382+ @ Test
383+ public void testNonUsRegionsSetsCorrectStackURL () throws Exception {
384+ Map <com .contentstack .sdk .Config .ContentstackRegion , String > expectedHosts = new HashMap <>();
385+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .EU , "eu-cdn.contentstack.io" );
386+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .AU , "au-cdn.contentstack.com" );
387+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .AZURE_NA , "azure-na-cdn.contentstack.com" );
388+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .AZURE_EU , "azure-eu-cdn.contentstack.com" );
389+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .GCP_NA , "gcp-na-cdn.contentstack.com" );
390+ expectedHosts .put (com .contentstack .sdk .Config .ContentstackRegion .GCP_EU , "gcp-eu-cdn.contentstack.com" );
391+
392+ for (Map .Entry <com .contentstack .sdk .Config .ContentstackRegion , String > entry : expectedHosts .entrySet ()) {
393+ com .contentstack .sdk .Config config = new com .contentstack .sdk .Config ();
394+ config .setRegion (entry .getKey ());
395+ Stack regionalStack = Contentstack .stack (mockContext , "api_key" , "token" , "env" , config );
396+ assertEquals (
397+ "Stack.URL mismatch for region " + entry .getKey (),
398+ entry .getValue (),
399+ regionalStack .URL
400+ );
401+ }
402+ }
403+
372404 @ Test
373405 public void testContentTypeEntryCreation () {
374406 ContentType contentType = stack .contentType ("products" );
0 commit comments