use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class FCMMessageMapperTest method test_normalMessage_fromJson_withoutNormalData.
public void test_normalMessage_fromJson_withoutNormalData() throws Exception {
String internalData = "{" + "\"silent\":" + "{" + "\"title\":\"silentTitle\"," + "\"body\":\"silentBody\"," + "\"sound\":\"silentSound\"," + "\"category\":\"silentCategory\"" + "}" + "}";
Bundle bundle = new Bundle();
bundle.putString("gcm.notification.e", "1");
bundle.putString("gcm.notification.messageId", "L+auqUQFlo1yqk2TEakxua/4rc6DmGgm7cM6G0GRQjU=");
bundle.putString("android.support.content.wakelockid", "11");
bundle.putString("collapse_key", "org.infobip.mobile.messaging.showcase.dev");
bundle.putString("internalData", internalData);
Message message = FCMMessageMapper.fromCloudBundle(bundle);
assertNotEquals("silentTitle", message.getTitle());
assertNotEquals("silentBody", message.getBody());
assertNotEquals("silentSound", message.getSound());
assertNotEquals("silentCategory", message.getCategory());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class FCMMessageMapperTest method test_bundleWithAttachments_intoMessageWithContentUrl.
public void test_bundleWithAttachments_intoMessageWithContentUrl() throws Exception {
String internalData = "{" + "\"atts\" : [{" + "\"url\":\"someUrl\"" + "}]" + "}";
Bundle bundle = new Bundle();
bundle.putString("internalData", internalData);
Message message = FCMMessageMapper.fromCloudBundle(bundle);
assertEquals("someUrl", message.getContentUrl());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class FCMMessageMapperTest method test_customData.
public void test_customData() throws Exception {
String customPayload = "{" + "\"key1\":\"value1\"," + "\"key2\":\"value2\"," + "\"key3\":\"value3\"" + "}";
Bundle bundle = new Bundle();
bundle.putString("customPayload", customPayload);
Message message = FCMMessageMapper.fromCloudBundle(bundle);
JSONAssert.assertEquals(customPayload, message.getCustomPayload(), true);
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class FCMMessageMapperTest method test_normalMessage_fromJson_withNormalData.
public void test_normalMessage_fromJson_withNormalData() throws Exception {
String internalData = "{" + "\"silent\":" + "{" + "\"title\":\"silentTitle\"," + "\"body\":\"silentBody\"," + "\"sound\":\"silentSound\"," + "\"category\":\"silentCategory\"" + "}" + "}";
Bundle bundle = new Bundle();
bundle.putString("gcm.notification.e", "1");
bundle.putString("gcm.notification.messageId", "L+auqUQFlo1yqk2TEakxua/4rc6DmGgm7cM6G0GRQjU=");
bundle.putString("android.support.content.wakelockid", "11");
bundle.putString("collapse_key", "org.infobip.mobile.messaging.showcase.dev");
bundle.putString("gcm.notification.title", "notSilentTitle");
bundle.putString("gcm.notification.body", "notSilentBody");
bundle.putString("gcm.notification.sound", "notSilentSound");
bundle.putString("gcm.notification.category", "notSilentCategory");
bundle.putString("internalData", internalData);
Message message = FCMMessageMapper.fromCloudBundle(bundle);
assertEquals("notSilentTitle", message.getTitle());
assertEquals("notSilentBody", message.getBody());
assertEquals("notSilentSound", message.getSound());
assertEquals("notSilentCategory", message.getCategory());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class FCMMessageMapperTest method test_fromBundle_success.
public void test_fromBundle_success() throws Exception {
Bundle plainBundle = new Bundle();
plainBundle.putString("gcm.notification.messageId", "1234");
plainBundle.putString("gcm.notification.sound", "some sound");
plainBundle.putString("gcm.notification.body", "lala");
plainBundle.putString("gcm.notification.title", "title");
plainBundle.putString("from", "from");
plainBundle.putString("gcm.notification.icon", "some icon");
plainBundle.putString("gcm.notification.silent", "false");
Message message = FCMMessageMapper.fromCloudBundle(plainBundle);
assertEquals(message.getMessageId(), "1234");
assertEquals(message.getSound(), "some sound");
assertEquals(message.getBody(), "lala");
assertEquals(message.getTitle(), "title");
assertEquals(message.getFrom(), "from");
assertEquals(message.getIcon(), "some icon");
assertEquals(message.isSilent(), false);
}
Aggregations