Skip to content

Commit

Permalink
fix(notification-data): flatten notification method to fix JSON forma…
Browse files Browse the repository at this point in the history
…t for flutter wrapper

SUITEDEV-35148

Co-authored-by: megamegax <[email protected]>
  • Loading branch information
LordAndras and megamegax committed Feb 2, 2024
1 parent 37522e9 commit 9d8f296
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.emarsys.mobileengage.event.EventServiceInternal
import com.emarsys.mobileengage.iam.OverlayInAppPresenter
import com.emarsys.mobileengage.service.IntentUtils
import com.emarsys.mobileengage.service.NotificationData
import com.emarsys.mobileengage.service.NotificationMethod
import com.emarsys.mobileengage.service.NotificationOperation
import com.emarsys.testUtil.ConnectionTestUtils
import com.emarsys.testUtil.DatabaseTestUtils
Expand Down Expand Up @@ -137,7 +136,8 @@ class InappNotificationIntegrationTest {
sid = SID,
smallIconResourceId = 123,
colorResourceId = 456,
notificationMethod = NotificationMethod("testCollapseId", NotificationOperation.UPDATE),
collapseId = "collapseId",
operation = NotificationOperation.INIT.name,
actions = null,
defaultAction = null,
inapp = inappPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import com.emarsys.mobileengage.di.tearDownMobileEngageComponent
import com.emarsys.mobileengage.event.CacheableEventHandler
import com.emarsys.mobileengage.event.EventServiceInternal
import com.emarsys.mobileengage.fake.FakeMobileEngageDependencyContainer
import com.emarsys.mobileengage.notification.command.*
import com.emarsys.mobileengage.notification.command.AppEventCommand
import com.emarsys.mobileengage.notification.command.CompositeCommand
import com.emarsys.mobileengage.notification.command.CustomEventCommand
import com.emarsys.mobileengage.notification.command.DismissNotificationCommand
import com.emarsys.mobileengage.notification.command.LaunchApplicationCommand
import com.emarsys.mobileengage.notification.command.NotificationInformationCommand
import com.emarsys.mobileengage.notification.command.OpenExternalUrlCommand
import com.emarsys.mobileengage.notification.command.TrackActionClickCommand
import com.emarsys.mobileengage.notification.command.TrackMessageOpenCommand
import com.emarsys.mobileengage.push.PushInternal
import com.emarsys.mobileengage.service.IntentUtils
import com.emarsys.mobileengage.service.NotificationData
Expand Down Expand Up @@ -49,7 +57,7 @@ class NotificationCommandFactoryTest {
const val MULTICHANNEL_ID = "test multiChannel id"
const val SMALL_RESOURCE_ID = 123
const val COLOR_RESOURCE_ID = 456
val notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE)
val notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.INIT)
val notificationData = NotificationData(
null,
null,
Expand All @@ -61,7 +69,8 @@ class NotificationCommandFactoryTest {
sid = SID,
smallIconResourceId = SMALL_RESOURCE_ID,
colorResourceId = COLOR_RESOURCE_ID,
notificationMethod = notificationMethod,
collapseId = COLLAPSE_ID,
operation = NotificationOperation.INIT.name,
actions = null,
defaultAction = null,
inapp = null
Expand Down Expand Up @@ -422,7 +431,8 @@ class NotificationCommandFactoryTest {
"sid" to SID,
"smallIconResourceId" to SMALL_RESOURCE_ID,
"colorResourceId" to COLOR_RESOURCE_ID,
"notificationMethod" to notificationMethod.toString(),
"collapseId" to COLLAPSE_ID,
"operation" to notificationMethod.operation.name,
"actions" to JSONArray(
listOf(
JSONObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import com.emarsys.mobileengage.service.NotificationData
import com.emarsys.mobileengage.service.NotificationMethod
import com.emarsys.mobileengage.service.NotificationOperation
import com.emarsys.testUtil.TimeoutUtils
import org.junit.Rule
Expand All @@ -25,6 +24,7 @@ class DismissNotificationCommandTest {
const val SID = "test sid"
const val SMALL_RESOURCE_ID = 123
const val COLOR_RESOURCE_ID = 456
val OPERATION = NotificationOperation.INIT.name
val notificationData = NotificationData(
null,
null,
Expand All @@ -36,7 +36,8 @@ class DismissNotificationCommandTest {
sid = SID,
smallIconResourceId = SMALL_RESOURCE_ID,
colorResourceId = COLOR_RESOURCE_ID,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.emarsys.mobileengage.di.setupMobileEngageComponent
import com.emarsys.mobileengage.di.tearDownMobileEngageComponent
import com.emarsys.mobileengage.fake.FakeMobileEngageDependencyContainer
import com.emarsys.mobileengage.service.NotificationData
import com.emarsys.mobileengage.service.NotificationMethod
import com.emarsys.mobileengage.service.NotificationOperation
import com.emarsys.testUtil.FileTestUtils
import com.emarsys.testUtil.InstrumentationRegistry
Expand Down Expand Up @@ -52,7 +51,8 @@ class PreloadedInappHandlerCommandTest {
sid = SID,
smallIconResourceId = SMALL_RESOURCE_ID,
colorResourceId = COLOR_RESOURCE_ID,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = NotificationOperation.INIT.name,
actions = null,
inapp = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class IntentUtilsTest {
sid = SID,
smallIconResourceId = SMALL_RESOURCE_ID,
colorResourceId = COLOR_RESOURCE_ID,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = NotificationOperation.INIT.name,
actions = null,
inapp = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class MessagingServiceUtilsTest {
const val IMAGE_URL = "https://emarsys.com/image"
const val ICON_URL = "https://emarsys.com/icon_image"
const val HTML_URL = "https://hu.wikipedia.org/wiki/Mont_Blanc"
const val COLLAPSE_ID = "testCollapseId"
const val COLOR = R.color.darker_gray
const val MULTICHANNEL_ID = "test multiChannel id"
const val SID = "test sid"
const val COLLAPSE_ID = "testCollapseId"
val OPERATION = NotificationOperation.INIT.name

val SMALL_NOTIFICATION_ICON =
com.emarsys.mobileengage.R.drawable.default_small_notification_icon
val NOTIFICATION_METHOD = NotificationMethod(COLLAPSE_ID, NotificationOperation.INIT)
val EMPTY_NOTIFICATION_DATA: NotificationData = NotificationData(
null,
null,
Expand All @@ -79,7 +79,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NOTIFICATION_METHOD,
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -228,9 +229,10 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
inapp = null,
)

val ems = JSONObject()
Expand Down Expand Up @@ -296,7 +298,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand All @@ -322,9 +325,10 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
inapp = null,
)

val input: MutableMap<String, String> = HashMap()
Expand Down Expand Up @@ -358,7 +362,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -393,7 +398,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -423,7 +429,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -456,7 +463,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -489,7 +497,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = colorResourceId,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -520,7 +529,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = invalidColor,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -549,7 +559,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -578,7 +589,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -614,7 +626,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -668,7 +681,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = actions.toString(),
inapp = null
)
Expand Down Expand Up @@ -710,7 +724,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -744,7 +759,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -865,7 +881,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand All @@ -889,7 +906,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
Expand Down Expand Up @@ -949,7 +967,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = actions,
inapp = null
)
Expand Down Expand Up @@ -1007,7 +1026,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = actions,
inapp = null
)
Expand Down Expand Up @@ -1051,7 +1071,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
),
Expand Down Expand Up @@ -1083,7 +1104,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
),
Expand Down Expand Up @@ -1119,7 +1141,8 @@ class MessagingServiceUtilsTest {
sid = SID,
smallIconResourceId = SMALL_NOTIFICATION_ICON,
colorResourceId = COLOR,
notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE),
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ class NotificationActionUtilsTest {
const val COLOR_RESOURCE_ID = 456
const val SID = "test sid"
const val MULTICHANNEL_ID = "test multichannel id"
const val COLLAPSE_ID = "testCollapseId"
val OPERATION = NotificationOperation.INIT.name
val testNotificationData = NotificationData(
campaignId = MULTICHANNEL_ID,
sid = SID,
smallIconResourceId = SMALL_RESOURCE_ID,
colorResourceId = COLOR_RESOURCE_ID,
notificationMethod = NotificationMethod("123", NotificationOperation.INIT),
inapp = null,
actions = null
collapseId = COLLAPSE_ID,
operation = OPERATION,
actions = null,
inapp = null
)
}

Expand Down
Loading

0 comments on commit 9d8f296

Please sign in to comment.