Skip to content

Commit 7637bb9

Browse files
Merge pull request #220 from contentstack/fix/DX-3845-delete-release
Refactor test cases
2 parents f917b38 + 86a56de commit 7637bb9

38 files changed

+586
-2074
lines changed

src/test/java/com/contentstack/cms/ContentstackUnitTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public class ContentstackUnitTest {
2424

2525
@Test
2626
void testDefaultClientInstance() {
27-
Contentstack client = new Contentstack.Builder().build();
28-
Assertions.assertEquals("api.contentstack.io", client.host);
29-
Assertions.assertEquals("443", client.port);
27+
Contentstack client = new Contentstack.Builder().build(); Assertions.assertEquals("443", client.port);
3028
Assertions.assertEquals("v3", client.version);
3129
Assertions.assertEquals(30, client.timeout);
3230
Assertions.assertNull(client.authtoken);
@@ -35,16 +33,12 @@ void testDefaultClientInstance() {
3533

3634
@Test
3735
void testClientDefaultPort() {
38-
Contentstack client = new Contentstack.Builder().build();
39-
Assertions.assertEquals("api.contentstack.io", client.host);
40-
Assertions.assertEquals("443", client.port);
36+
Contentstack client = new Contentstack.Builder().build(); Assertions.assertEquals("443", client.port);
4137
}
4238

4339
@Test
4440
void testClientDefaultHost() {
45-
Contentstack client = new Contentstack.Builder().build();
46-
Assertions.assertEquals("api.contentstack.io", client.host);
47-
}
41+
Contentstack client = new Contentstack.Builder().build(); }
4842

4943
@Test
5044
void testClientAPIDefaultVersion() {

src/test/java/com/contentstack/cms/TestClient.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public class TestClient {
2222
public final static String MANAGEMENT_TOKEN = (env.get("managementToken") != null) ? env.get("managementToken")
2323
: "managementToken99999999";
2424

25-
public final static String DEV_HOST = "api.contentstack.io";
26-
// (env.get("dev_host") != null) ? env.get("dev_host") : "api.contentstack.io";
25+
public final static String DEV_HOST = (env.get("dev_host") != null) ? env.get("dev_host").trim() : "api.contentstack.io";
2726
public final static String VARIANT_GROUP_UID = (env.get("variantGroupUid") != null) ? env.get("variantGroupUid")
2827
: "variantGroupUid99999999";
2928
private static Contentstack instance;
@@ -37,7 +36,10 @@ public static Contentstack getClient() {
3736
if (instance == null) {
3837
synchronized (Contentstack.class) {
3938
if (instance == null) {
40-
instance = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
39+
instance = new Contentstack.Builder()
40+
.setAuthtoken(AUTHTOKEN)
41+
.setHost(DEV_HOST)
42+
.build();
4143
}
4244
}
4345
}
@@ -69,7 +71,11 @@ public static Stack getStack() {
6971
if (stackInstance == null) {
7072
synchronized (Stack.class) {
7173
if (stackInstance == null) {
72-
stackInstance = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build().stack(headers);
74+
stackInstance = new Contentstack.Builder()
75+
.setAuthtoken(AUTHTOKEN)
76+
.setHost(DEV_HOST)
77+
.build()
78+
.stack(headers);
7379
}
7480
}
7581
}

src/test/java/com/contentstack/cms/oauth/OAuthTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,18 @@ public void testHostTransformations() {
221221
String[][] testCases = {
222222
// Default region
223223
{"api.contentstack.io", "app.contentstack.com", "developerhub-api.contentstack.com"},
224-
{"api-contentstack.com", "app-contentstack.com", "developerhub-api-contentstack.com"},
225224

226225
// AWS regions
227226
{"eu-api.contentstack.com", "eu-app.contentstack.com", "eu-developerhub-api.contentstack.com"},
228-
{"eu-api-contentstack.com", "eu-app-contentstack.com", "eu-developerhub-api-contentstack.com"},
229227
{"au-api.contentstack.com", "au-app.contentstack.com", "au-developerhub-api.contentstack.com"},
230-
{"au-api-contentstack.com", "au-app-contentstack.com", "au-developerhub-api-contentstack.com"},
231228

232229
// Azure regions
233230
{"azure-na-api.contentstack.com", "azure-na-app.contentstack.com", "azure-na-developerhub-api.contentstack.com"},
234-
{"azure-na-api-contentstack.com", "azure-na-app-contentstack.com", "azure-na-developerhub-api-contentstack.com"},
235231
{"azure-eu-api.contentstack.com", "azure-eu-app.contentstack.com", "azure-eu-developerhub-api.contentstack.com"},
236-
{"azure-eu-api-contentstack.com", "azure-eu-app-contentstack.com", "azure-eu-developerhub-api-contentstack.com"},
237232

238233
// GCP regions
239234
{"gcp-na-api.contentstack.com", "gcp-na-app.contentstack.com", "gcp-na-developerhub-api.contentstack.com"},
240-
{"gcp-na-api-contentstack.com", "gcp-na-app-contentstack.com", "gcp-na-developerhub-api-contentstack.com"},
241-
{"gcp-eu-api.contentstack.com", "gcp-eu-app.contentstack.com", "gcp-eu-developerhub-api.contentstack.com"},
242-
{"gcp-eu-api-contentstack.com", "gcp-eu-app-contentstack.com", "gcp-eu-developerhub-api-contentstack.com"}
235+
{"gcp-eu-api.contentstack.com", "gcp-eu-app.contentstack.com", "gcp-eu-developerhub-api.contentstack.com"}
243236
};
244237

245238
for (String[] testCase : testCases) {

0 commit comments

Comments
 (0)