|
| 1 | +package com.contentstack.sdk; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Assertions; |
| 4 | +import org.junit.jupiter.api.Test; |
| 5 | + |
| 6 | +class TestAzureRegion { |
| 7 | + |
| 8 | + @Test |
| 9 | + void testAzureRegion() { |
| 10 | + Assertions.assertTrue(true); |
| 11 | + } |
| 12 | + |
| 13 | + @Test |
| 14 | + void testAzureRegionBehaviourUS() { |
| 15 | + Config config = new Config(); |
| 16 | + Config.ContentstackRegion region = Config.ContentstackRegion.US; |
| 17 | + config.setRegion(region); |
| 18 | + Assertions.assertFalse(config.region.name().isEmpty()); |
| 19 | + Assertions.assertEquals("US", config.region.name()); |
| 20 | + } |
| 21 | + |
| 22 | + @Test |
| 23 | + void testAzureRegionBehaviourEU() { |
| 24 | + Config config = new Config(); |
| 25 | + Config.ContentstackRegion region = Config.ContentstackRegion.EU; |
| 26 | + config.setRegion(region); |
| 27 | + Assertions.assertFalse(config.region.name().isEmpty()); |
| 28 | + Assertions.assertEquals("EU", config.region.name()); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + void testAzureRegionBehaviourAzure() { |
| 33 | + Config config = new Config(); |
| 34 | + Config.ContentstackRegion region = Config.ContentstackRegion.AZURE_NA; |
| 35 | + config.setRegion(region); |
| 36 | + Assertions.assertFalse(config.region.name().isEmpty()); |
| 37 | + Assertions.assertEquals("AZURE_NA", config.region.name()); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + void testAzureRegionBehaviourAzureStack() throws IllegalAccessException { |
| 42 | + Config config = new Config(); |
| 43 | + Config.ContentstackRegion region = Config.ContentstackRegion.AZURE_NA; |
| 44 | + config.setRegion(region); |
| 45 | + Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config); |
| 46 | + Assertions.assertFalse(config.region.name().isEmpty()); |
| 47 | + Assertions.assertEquals("AZURE_NA", stack.config.region.name()); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + void testAzureRegionBehaviourAzureStackHost() throws IllegalAccessException { |
| 52 | + Config config = new Config(); |
| 53 | + Config.ContentstackRegion region = Config.ContentstackRegion.AZURE_NA; |
| 54 | + config.setRegion(region); |
| 55 | + Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config); |
| 56 | + Assertions.assertFalse(config.region.name().isEmpty()); |
| 57 | + Assertions.assertEquals("azure-na-cdn.contentstack.com", stack.config.host); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + void testAzureRegionBehaviourAzureStackInit() throws IllegalAccessException { |
| 62 | + Config config = new Config(); |
| 63 | + Config.ContentstackRegion region = Config.ContentstackRegion.AZURE_NA; |
| 64 | + config.setRegion(region); |
| 65 | + Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config); |
| 66 | + Query query = stack.contentType("fakeCT").query(); |
| 67 | + query.find(new QueryResultsCallBack() { |
| 68 | + @Override |
| 69 | + public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { |
| 70 | + System.out.println("So something here..."); |
| 71 | + } |
| 72 | + }); |
| 73 | + Assertions.assertEquals("azure-na-cdn.contentstack.com", stack.config.host); |
| 74 | + } |
| 75 | + |
| 76 | + @Test |
| 77 | + void testAzureRegionBehaviourEUStack() throws IllegalAccessException { |
| 78 | + Config config = new Config(); |
| 79 | + Config.ContentstackRegion region = Config.ContentstackRegion.EU; |
| 80 | + config.setRegion(region); |
| 81 | + Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config); |
| 82 | + Query query = stack.contentType("fakeCT").query(); |
| 83 | + query.find(new QueryResultsCallBack() { |
| 84 | + @Override |
| 85 | + public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { |
| 86 | + System.out.println("So something here..."); |
| 87 | + } |
| 88 | + }); |
| 89 | + Assertions.assertEquals("eu-cdn.contentstack.com", stack.config.host); |
| 90 | + } |
| 91 | +} |
0 commit comments