Skip to content

Commit 186dd58

Browse files
authored
Merge pull request #238 from contentstack/fix/DX-3455-error-message-improve
fixed test assertions
2 parents 072eb9b + ab33952 commit 186dd58

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/test/java/com/contentstack/sdk/TestContentType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void testPrivateAccess() {
1919
try {
2020
new ContentType();
2121
} catch (IllegalAccessException e) {
22-
Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage());
22+
Assertions.assertEquals("Direct instantiation of ContentType is not allowed. Use Stack.contentType(uid) to create an instance.", e.getLocalizedMessage());
2323
logger.info("passed...");
2424
}
2525
}

src/test/java/com/contentstack/sdk/TestContentstack.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void initStackPrivateModifier() {
2626
new Contentstack();
2727
} catch (Exception e) {
2828
logger.info(e.getLocalizedMessage());
29-
Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage());
29+
Assertions.assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", e.getLocalizedMessage());
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ void initStackWithEmptyAPIKey() {
6767
Contentstack.stack("", DELIVERY_TOKEN, ENV);
6868
} catch (Exception e) {
6969
logger.info(e.getLocalizedMessage());
70-
Assertions.assertEquals("API Key can not be empty", e.getLocalizedMessage(), "Set APIKey Null");
70+
Assertions.assertEquals("Missing API key. Provide a valid key from your Contentstack stack settings and try again.", e.getLocalizedMessage(), "Set APIKey Null");
7171
}
7272
}
7373

@@ -77,7 +77,7 @@ void initStackWithEmptyDeliveryToken() {
7777
Contentstack.stack(API_KEY, "", ENV);
7878
} catch (Exception e) {
7979
logger.info(e.getLocalizedMessage());
80-
Assertions.assertEquals("Delivery Token can not be empty", e.getLocalizedMessage(),
80+
Assertions.assertEquals("Missing delivery token. Provide a valid token from your Contentstack stack settings and try again.", e.getLocalizedMessage(),
8181
"Set deliveryToken Null");
8282
}
8383
}
@@ -88,7 +88,7 @@ void initStackWithEmptyEnvironment() {
8888
Contentstack.stack(API_KEY, DELIVERY_TOKEN, "");
8989
} catch (Exception e) {
9090
logger.info(e.getLocalizedMessage());
91-
Assertions.assertEquals("Environment can not be empty", e.getLocalizedMessage(), "Set Environment Null");
91+
Assertions.assertEquals("Missing environment. Provide a valid environment name and try again.", e.getLocalizedMessage(), "Set Environment Null");
9292
}
9393
}
9494

src/test/java/com/contentstack/sdk/TestEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void entryCallingPrivateModifier() {
2525
try {
2626
new Entry();
2727
} catch (IllegalAccessException e) {
28-
Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage());
28+
Assertions.assertEquals("Direct instantiation of Entry is not allowed. Use ContentType.entry(uid) to create an instance.", e.getLocalizedMessage());
2929
logger.info("passed.");
3030
}
3131
}

src/test/java/com/contentstack/sdk/TestLivePreview.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void testLivePreviewWithoutPreviewToken() throws Exception {
197197
stack.livePreviewQuery(hashMap);
198198
}, "Expected livePreviewQuery to throw IllegalAccessError");
199199

200-
Assertions.assertTrue(thrown.getMessage().contains("Provide the Preview Token for the host rest-preview.contentstack.com"),
200+
Assertions.assertTrue(thrown.getMessage().contains("Missing preview token for rest-preview.contentstack.com"),
201201
"Exception message should mention that Preview Token is required");
202202

203203
logger.severe(thrown.getMessage());
@@ -220,7 +220,7 @@ void testLivePreviewDisabled() throws IllegalAccessException, IOException {
220220
});
221221

222222
// Optionally, you can check the message of the exception
223-
assertEquals("Live Preview is not enabled in Config", exception.getMessage(),
223+
assertEquals("Live Preview is not enabled in the configuration. Enable it and try again.", exception.getMessage(),
224224
"Expected exception message does not match");
225225
}
226226

src/test/java/com/contentstack/sdk/TestStack.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TestStack {
2525
@Order(1)
2626
void stackExceptionTesting() {
2727
IllegalAccessException thrown = Assertions.assertThrows(IllegalAccessException.class, Stack::new,
28-
"Can Not Access Private Modifier");
29-
assertEquals("Can Not Access Private Modifier", thrown.getLocalizedMessage());
28+
"Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.");
29+
assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", thrown.getLocalizedMessage());
3030
}
3131

3232
@Test
@@ -35,7 +35,7 @@ void testStackInitThrowErr() {
3535
try {
3636
stack = new Stack();
3737
} catch (IllegalAccessException e) {
38-
assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage());
38+
assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", e.getLocalizedMessage());
3939
}
4040
}
4141

0 commit comments

Comments
 (0)