From f290ee406c50815d3938f4ed990300385a2bba0f Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Tue, 27 Jan 2026 13:53:03 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=94=A7=20Updated=20customPayload=20to?= =?UTF-8?q?=20be=20Nullable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iterable/iterableapi/IterableInAppMessage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppMessage.java b/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppMessage.java index 6b948a4b1..c049f3f6d 100644 --- a/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppMessage.java +++ b/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppMessage.java @@ -17,7 +17,7 @@ public class IterableInAppMessage { private final @NonNull String messageId; private final @NonNull Content content; - private final @NonNull JSONObject customPayload; + private final @Nullable JSONObject customPayload; private final @NonNull Date createdAt; private final @NonNull Date expiresAt; private final @NonNull Trigger trigger; @@ -35,7 +35,7 @@ public class IterableInAppMessage { IterableInAppMessage(@NonNull String messageId, @NonNull Content content, - @NonNull JSONObject customPayload, + @Nullable JSONObject customPayload, @NonNull Date createdAt, @NonNull Date expiresAt, @NonNull Trigger trigger, @@ -255,7 +255,7 @@ public Content getContent() { return content; } - @NonNull + @Nullable public JSONObject getCustomPayload() { return customPayload; } From 1fe251a2f86dfb5a00943afc309f65e003e25f2f Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Tue, 27 Jan 2026 13:53:12 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A7=AA=20Added=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iterableapi/IterableInAppMessageTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java index 69e1b9187..20c5ab29b 100644 --- a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java +++ b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java @@ -47,6 +47,23 @@ public void testInAppMessageDeserialization() throws Exception { } } + @Test + public void testHtmlMessageWithoutCustomPayload() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("content", new JSONObject() + .put("html", "Test") + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNotNull(message); + assertNull(message.getCustomPayload()); + } + @Test public void testInAppLegacyPayloadDeserialization() throws Exception { JSONObject payload = new JSONObject(IterableTestUtils.getResourceString("inapp_payload_legacy.json")); From acc7eab0cca9706a561e9d5419e6800219e348ac Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Tue, 27 Jan 2026 14:59:31 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=A7=AA=20Added=20more=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iterableapi/IterableInAppMessageTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java index 20c5ab29b..1bb613296 100644 --- a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java +++ b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java @@ -11,6 +11,7 @@ import org.skyscreamer.jsonassert.JSONCompareMode; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -64,6 +65,76 @@ public void testHtmlMessageWithoutCustomPayload() throws Exception { assertNull(message.getCustomPayload()); } + @Test + public void testEmptyCustomPayloadReturnsEmptyObject() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("customPayload", new JSONObject()) + .put("content", new JSONObject() + .put("html", "Test") + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNotNull(message.getCustomPayload()); + assertEquals(0, message.getCustomPayload().length()); + } + + @Test + public void testNullCustomPayloadSerializationRoundTrip() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("content", new JSONObject() + .put("html", "Test") + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNull(message.getCustomPayload()); + + JSONObject serialized = message.toJSONObject(); + assertFalse(serialized.has("customPayload")); + + IterableInAppMessage rehydrated = IterableInAppMessage.fromJSONObject(serialized, null); + assertNull(rehydrated.getCustomPayload()); + } + + @Test + public void testCustomPayloadTakesPrecedenceOverLegacyPayload() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("customPayload", new JSONObject().put("source", "customPayload")) + .put("content", new JSONObject() + .put("html", "Test") + .put("payload", new JSONObject().put("source", "legacyPayload")) + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertEquals("customPayload", message.getCustomPayload().getString("source")); + } + + @Test + public void testJsonOnlyWithoutCustomPayloadReturnsEmptyObject() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("jsonOnly", true) + .put("trigger", new JSONObject().put("type", "never")); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNotNull(message.getCustomPayload()); + assertEquals(0, message.getCustomPayload().length()); + } + @Test public void testInAppLegacyPayloadDeserialization() throws Exception { JSONObject payload = new JSONObject(IterableTestUtils.getResourceString("inapp_payload_legacy.json")); From 9315c79d0510e677f9343dd01684bb17327ddb48 Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Wed, 28 Jan 2026 16:43:21 +0000 Subject: [PATCH 4/6] =?UTF-8?q?Revert=20"=F0=9F=A7=AA=20Added=20more=20uni?= =?UTF-8?q?t=20tests"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit acc7eab0cca9706a561e9d5419e6800219e348ac. --- .../iterableapi/IterableInAppMessageTest.java | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java index 1bb613296..20c5ab29b 100644 --- a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java +++ b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java @@ -11,7 +11,6 @@ import org.skyscreamer.jsonassert.JSONCompareMode; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -65,76 +64,6 @@ public void testHtmlMessageWithoutCustomPayload() throws Exception { assertNull(message.getCustomPayload()); } - @Test - public void testEmptyCustomPayloadReturnsEmptyObject() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("customPayload", new JSONObject()) - .put("content", new JSONObject() - .put("html", "Test") - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNotNull(message.getCustomPayload()); - assertEquals(0, message.getCustomPayload().length()); - } - - @Test - public void testNullCustomPayloadSerializationRoundTrip() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("content", new JSONObject() - .put("html", "Test") - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNull(message.getCustomPayload()); - - JSONObject serialized = message.toJSONObject(); - assertFalse(serialized.has("customPayload")); - - IterableInAppMessage rehydrated = IterableInAppMessage.fromJSONObject(serialized, null); - assertNull(rehydrated.getCustomPayload()); - } - - @Test - public void testCustomPayloadTakesPrecedenceOverLegacyPayload() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("customPayload", new JSONObject().put("source", "customPayload")) - .put("content", new JSONObject() - .put("html", "Test") - .put("payload", new JSONObject().put("source", "legacyPayload")) - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertEquals("customPayload", message.getCustomPayload().getString("source")); - } - - @Test - public void testJsonOnlyWithoutCustomPayloadReturnsEmptyObject() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("jsonOnly", true) - .put("trigger", new JSONObject().put("type", "never")); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNotNull(message.getCustomPayload()); - assertEquals(0, message.getCustomPayload().length()); - } - @Test public void testInAppLegacyPayloadDeserialization() throws Exception { JSONObject payload = new JSONObject(IterableTestUtils.getResourceString("inapp_payload_legacy.json")); From 26237ad74369e25bfbb9dbaf7c98b8716796d407 Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Wed, 28 Jan 2026 17:04:52 +0000 Subject: [PATCH 5/6] =?UTF-8?q?Reapply=20"=F0=9F=A7=AA=20Added=20more=20un?= =?UTF-8?q?it=20tests"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9315c79d0510e677f9343dd01684bb17327ddb48. --- .../iterableapi/IterableInAppMessageTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java index 20c5ab29b..1bb613296 100644 --- a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java +++ b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java @@ -11,6 +11,7 @@ import org.skyscreamer.jsonassert.JSONCompareMode; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -64,6 +65,76 @@ public void testHtmlMessageWithoutCustomPayload() throws Exception { assertNull(message.getCustomPayload()); } + @Test + public void testEmptyCustomPayloadReturnsEmptyObject() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("customPayload", new JSONObject()) + .put("content", new JSONObject() + .put("html", "Test") + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNotNull(message.getCustomPayload()); + assertEquals(0, message.getCustomPayload().length()); + } + + @Test + public void testNullCustomPayloadSerializationRoundTrip() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("content", new JSONObject() + .put("html", "Test") + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNull(message.getCustomPayload()); + + JSONObject serialized = message.toJSONObject(); + assertFalse(serialized.has("customPayload")); + + IterableInAppMessage rehydrated = IterableInAppMessage.fromJSONObject(serialized, null); + assertNull(rehydrated.getCustomPayload()); + } + + @Test + public void testCustomPayloadTakesPrecedenceOverLegacyPayload() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("customPayload", new JSONObject().put("source", "customPayload")) + .put("content", new JSONObject() + .put("html", "Test") + .put("payload", new JSONObject().put("source", "legacyPayload")) + .put("inAppDisplaySettings", new JSONObject() + .put("top", new JSONObject().put("percentage", 0)) + .put("right", new JSONObject().put("percentage", 0)) + .put("bottom", new JSONObject().put("percentage", 0)) + .put("left", new JSONObject().put("percentage", 0)))); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertEquals("customPayload", message.getCustomPayload().getString("source")); + } + + @Test + public void testJsonOnlyWithoutCustomPayloadReturnsEmptyObject() throws Exception { + JSONObject messageJson = new JSONObject() + .put("messageId", "test123") + .put("jsonOnly", true) + .put("trigger", new JSONObject().put("type", "never")); + + IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); + assertNotNull(message.getCustomPayload()); + assertEquals(0, message.getCustomPayload().length()); + } + @Test public void testInAppLegacyPayloadDeserialization() throws Exception { JSONObject payload = new JSONObject(IterableTestUtils.getResourceString("inapp_payload_legacy.json")); From c0e3dee05b4d389fcbfd4ca5ef9b60d7ba4235e1 Mon Sep 17 00:00:00 2001 From: Joao Dordio Date: Wed, 28 Jan 2026 17:34:10 +0000 Subject: [PATCH 6/6] =?UTF-8?q?Revert=20"Reapply=20"=F0=9F=A7=AA=20Added?= =?UTF-8?q?=20more=20unit=20tests""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 26237ad74369e25bfbb9dbaf7c98b8716796d407. --- .../iterableapi/IterableInAppMessageTest.java | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java index 1bb613296..20c5ab29b 100644 --- a/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java +++ b/iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppMessageTest.java @@ -11,7 +11,6 @@ import org.skyscreamer.jsonassert.JSONCompareMode; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -65,76 +64,6 @@ public void testHtmlMessageWithoutCustomPayload() throws Exception { assertNull(message.getCustomPayload()); } - @Test - public void testEmptyCustomPayloadReturnsEmptyObject() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("customPayload", new JSONObject()) - .put("content", new JSONObject() - .put("html", "Test") - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNotNull(message.getCustomPayload()); - assertEquals(0, message.getCustomPayload().length()); - } - - @Test - public void testNullCustomPayloadSerializationRoundTrip() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("content", new JSONObject() - .put("html", "Test") - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNull(message.getCustomPayload()); - - JSONObject serialized = message.toJSONObject(); - assertFalse(serialized.has("customPayload")); - - IterableInAppMessage rehydrated = IterableInAppMessage.fromJSONObject(serialized, null); - assertNull(rehydrated.getCustomPayload()); - } - - @Test - public void testCustomPayloadTakesPrecedenceOverLegacyPayload() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("customPayload", new JSONObject().put("source", "customPayload")) - .put("content", new JSONObject() - .put("html", "Test") - .put("payload", new JSONObject().put("source", "legacyPayload")) - .put("inAppDisplaySettings", new JSONObject() - .put("top", new JSONObject().put("percentage", 0)) - .put("right", new JSONObject().put("percentage", 0)) - .put("bottom", new JSONObject().put("percentage", 0)) - .put("left", new JSONObject().put("percentage", 0)))); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertEquals("customPayload", message.getCustomPayload().getString("source")); - } - - @Test - public void testJsonOnlyWithoutCustomPayloadReturnsEmptyObject() throws Exception { - JSONObject messageJson = new JSONObject() - .put("messageId", "test123") - .put("jsonOnly", true) - .put("trigger", new JSONObject().put("type", "never")); - - IterableInAppMessage message = IterableInAppMessage.fromJSONObject(messageJson, null); - assertNotNull(message.getCustomPayload()); - assertEquals(0, message.getCustomPayload().length()); - } - @Test public void testInAppLegacyPayloadDeserialization() throws Exception { JSONObject payload = new JSONObject(IterableTestUtils.getResourceString("inapp_payload_legacy.json"));