Skip to content

Commit

Permalink
Merge pull request #528 from adobe/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
praveek authored Aug 8, 2023
2 parents 8195cbb + cd1530d commit d41c1da
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package com.adobe.marketing.mobile.internal

internal object CoreConstants {
const val LOG_TAG = "MobileCore"
const val VERSION = "2.3.0"
const val VERSION = "2.3.1"

object EventDataKeys {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.adobe.marketing.mobile.services.ServiceConstants;
import com.adobe.marketing.mobile.services.ServiceProvider;
import com.adobe.marketing.mobile.services.ui.internal.MessagesMonitor;
import com.adobe.marketing.mobile.util.MapUtils;
import java.lang.reflect.Field;
import java.security.SecureRandom;
import java.util.Calendar;
Expand Down Expand Up @@ -241,9 +242,13 @@ public void showLocalNotification(final NotificationSetting notificationSetting)
intent.putExtra(NOTIFICATION_REQUEST_CODE_KEY, requestCode);
intent.putExtra(NOTIFICATION_DEEPLINK_KEY, notificationSetting.getDeeplink());
intent.putExtra(NOTIFICATION_CONTENT_KEY, notificationSetting.getContent());
intent.putExtra(
NOTIFICATION_USER_INFO_KEY,
(HashMap<String, Object>) notificationSetting.getUserInfo());
final HashMap<String, Object> userInfo =
!MapUtils.isNullOrEmpty(notificationSetting.getUserInfo())
? new HashMap<>(notificationSetting.getUserInfo())
: null;
if (!MapUtils.isNullOrEmpty(userInfo)) {
intent.putExtra(NOTIFICATION_USER_INFO_KEY, userInfo);
}
intent.putExtra(NOTIFICATION_SOUND_KEY, notificationSetting.getSound());
intent.putExtra(NOTIFICATION_TITLE, notificationSetting.getTitle());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import kotlin.test.assertTrue
@RunWith(MockitoJUnitRunner.Silent::class)
class MobileCoreTests {

private var EXTENSION_VERSION = "2.3.0"
private var EXTENSION_VERSION = "2.3.1"

@Mock
private lateinit var mockedEventHub: EventHub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import kotlin.test.assertTrue
@RunWith(MockitoJUnitRunner.Silent::class)
class ConfigurationExtensionTests {

private var EXTENSION_VERSION = "2.3.0"
private var EXTENSION_VERSION = "2.3.1"

@Mock
private lateinit var mockServiceProvider: ServiceProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
import com.adobe.marketing.mobile.services.ServiceProviderModifier;
import com.adobe.marketing.mobile.services.ui.internal.MessagesMonitor;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -353,6 +356,46 @@ public void localNotificationWithTitleIsNotShown_When_ContextIsNull() {
verify(mockAlarmManager, times(0)).set(eq(AlarmManager.RTC_WAKEUP), anyLong(), isNull());
}

@Test
public void localNotificationIsShown_When_UnmodifiableUserInfoMapIsProvided() {
// setup
Map<String, Object> userInfo =
new HashMap<String, Object>() {
{
put("key1", "value1");
put("key2", "value2");
}
};
when(mockMessagesMonitor.isDisplayed()).thenReturn(false);
androidUIService.messagesMonitor = mockMessagesMonitor;

when(mockContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mockAlarmManager);
when(mockContext.getApplicationContext()).thenReturn(mockContext);

when(mockAppContextService.getApplicationContext()).thenReturn(mockContext);
// test
androidUIService.showLocalNotification(
NotificationSetting.build(
"id",
"content",
123456,
123,
"myscheme://link",
Collections.unmodifiableMap(userInfo),
"sound.wav",
null));
// verify that the Alarm was set
ArgumentCaptor<Long> triggerTimeCaptor = ArgumentCaptor.forClass(long.class);
// The Pending Intent is null matched only because in this test we are not able to mock a
// static call
// to PendingIntent.getBroadcast() without using additional libraries - which is a no-no
verify(mockAlarmManager)
.set(eq(AlarmManager.RTC_WAKEUP), triggerTimeCaptor.capture(), isNull());
// verify that the alarm time is within the delta of 50ms :)
long expectedTriggerTime = getTriggerTimeForFireDate(123456);
assertTrue(triggerTimeCaptor.getValue() - expectedTriggerTime < 50);
}

@Test
public void showUrlStartsActivity_When_ValidUrl() {
// Setup
Expand Down
2 changes: 1 addition & 1 deletion code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android.useAndroidX=true
#
#Maven artifacts
#Core extension
coreExtensionVersion=2.3.0
coreExtensionVersion=2.3.1
coreExtensionName=core
coreExtensionAARName=core-phone-release.aar
coreMavenRepoName=AdobeMobileCoreSdk
Expand Down

0 comments on commit d41c1da

Please sign in to comment.