From ab339528f21f467ab7abd96e0c8e84e7c9c7653d Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Tue, 28 Oct 2025 16:59:22 +0530 Subject: [PATCH] fixed test assertions --- src/test/java/com/contentstack/sdk/TestContentType.java | 2 +- src/test/java/com/contentstack/sdk/TestContentstack.java | 8 ++++---- src/test/java/com/contentstack/sdk/TestEntry.java | 2 +- src/test/java/com/contentstack/sdk/TestLivePreview.java | 4 ++-- src/test/java/com/contentstack/sdk/TestStack.java | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/contentstack/sdk/TestContentType.java b/src/test/java/com/contentstack/sdk/TestContentType.java index 2948f9bf..731591ee 100644 --- a/src/test/java/com/contentstack/sdk/TestContentType.java +++ b/src/test/java/com/contentstack/sdk/TestContentType.java @@ -19,7 +19,7 @@ void testPrivateAccess() { try { new ContentType(); } catch (IllegalAccessException e) { - Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage()); + Assertions.assertEquals("Direct instantiation of ContentType is not allowed. Use Stack.contentType(uid) to create an instance.", e.getLocalizedMessage()); logger.info("passed..."); } } diff --git a/src/test/java/com/contentstack/sdk/TestContentstack.java b/src/test/java/com/contentstack/sdk/TestContentstack.java index 1a2fb41c..a5cf4f98 100644 --- a/src/test/java/com/contentstack/sdk/TestContentstack.java +++ b/src/test/java/com/contentstack/sdk/TestContentstack.java @@ -26,7 +26,7 @@ void initStackPrivateModifier() { new Contentstack(); } catch (Exception e) { logger.info(e.getLocalizedMessage()); - Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage()); + Assertions.assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", e.getLocalizedMessage()); } } @@ -67,7 +67,7 @@ void initStackWithEmptyAPIKey() { Contentstack.stack("", DELIVERY_TOKEN, ENV); } catch (Exception e) { logger.info(e.getLocalizedMessage()); - Assertions.assertEquals("API Key can not be empty", e.getLocalizedMessage(), "Set APIKey Null"); + Assertions.assertEquals("Missing API key. Provide a valid key from your Contentstack stack settings and try again.", e.getLocalizedMessage(), "Set APIKey Null"); } } @@ -77,7 +77,7 @@ void initStackWithEmptyDeliveryToken() { Contentstack.stack(API_KEY, "", ENV); } catch (Exception e) { logger.info(e.getLocalizedMessage()); - Assertions.assertEquals("Delivery Token can not be empty", e.getLocalizedMessage(), + Assertions.assertEquals("Missing delivery token. Provide a valid token from your Contentstack stack settings and try again.", e.getLocalizedMessage(), "Set deliveryToken Null"); } } @@ -88,7 +88,7 @@ void initStackWithEmptyEnvironment() { Contentstack.stack(API_KEY, DELIVERY_TOKEN, ""); } catch (Exception e) { logger.info(e.getLocalizedMessage()); - Assertions.assertEquals("Environment can not be empty", e.getLocalizedMessage(), "Set Environment Null"); + Assertions.assertEquals("Missing environment. Provide a valid environment name and try again.", e.getLocalizedMessage(), "Set Environment Null"); } } diff --git a/src/test/java/com/contentstack/sdk/TestEntry.java b/src/test/java/com/contentstack/sdk/TestEntry.java index 044ab5e3..b3311e29 100644 --- a/src/test/java/com/contentstack/sdk/TestEntry.java +++ b/src/test/java/com/contentstack/sdk/TestEntry.java @@ -25,7 +25,7 @@ void entryCallingPrivateModifier() { try { new Entry(); } catch (IllegalAccessException e) { - Assertions.assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage()); + Assertions.assertEquals("Direct instantiation of Entry is not allowed. Use ContentType.entry(uid) to create an instance.", e.getLocalizedMessage()); logger.info("passed."); } } diff --git a/src/test/java/com/contentstack/sdk/TestLivePreview.java b/src/test/java/com/contentstack/sdk/TestLivePreview.java index 98342989..29ac41da 100644 --- a/src/test/java/com/contentstack/sdk/TestLivePreview.java +++ b/src/test/java/com/contentstack/sdk/TestLivePreview.java @@ -197,7 +197,7 @@ void testLivePreviewWithoutPreviewToken() throws Exception { stack.livePreviewQuery(hashMap); }, "Expected livePreviewQuery to throw IllegalAccessError"); - Assertions.assertTrue(thrown.getMessage().contains("Provide the Preview Token for the host rest-preview.contentstack.com"), + Assertions.assertTrue(thrown.getMessage().contains("Missing preview token for rest-preview.contentstack.com"), "Exception message should mention that Preview Token is required"); logger.severe(thrown.getMessage()); @@ -220,7 +220,7 @@ void testLivePreviewDisabled() throws IllegalAccessException, IOException { }); // Optionally, you can check the message of the exception - assertEquals("Live Preview is not enabled in Config", exception.getMessage(), + assertEquals("Live Preview is not enabled in the configuration. Enable it and try again.", exception.getMessage(), "Expected exception message does not match"); } diff --git a/src/test/java/com/contentstack/sdk/TestStack.java b/src/test/java/com/contentstack/sdk/TestStack.java index 86d40953..2ed78552 100644 --- a/src/test/java/com/contentstack/sdk/TestStack.java +++ b/src/test/java/com/contentstack/sdk/TestStack.java @@ -25,8 +25,8 @@ class TestStack { @Order(1) void stackExceptionTesting() { IllegalAccessException thrown = Assertions.assertThrows(IllegalAccessException.class, Stack::new, - "Can Not Access Private Modifier"); - assertEquals("Can Not Access Private Modifier", thrown.getLocalizedMessage()); + "Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance."); + assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", thrown.getLocalizedMessage()); } @Test @@ -35,7 +35,7 @@ void testStackInitThrowErr() { try { stack = new Stack(); } catch (IllegalAccessException e) { - assertEquals("Can Not Access Private Modifier", e.getLocalizedMessage()); + assertEquals("Direct instantiation of Stack is not allowed. Use Contentstack.stack() to create an instance.", e.getLocalizedMessage()); } }