Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/SalesforceSDK/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
<string name="oauth_display_type">touch</string>

<!-- Default API version used by the SDK and sample apps -->
<string name="api_version">v63.0</string>
<string name="api_version">v66.0</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class ApiVersionStrings {

public static final String VERSION_NUMBER = "v63.0";
public static final String VERSION_NUMBER = "v66.0";

/** A version number override exclusively to support unit tests */
@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NotificationsApiClient(
val apiVersion = ApiVersionStrings.getVersionNumber(context)

// Submit the request.
if (apiVersion < "v64.0") { // TODO: Remove once MSDK default API version is 64 or greater.
if (apiVersion < "v64.0") {
SalesforceSDKLogger.w(TAG, "Cannot request Salesforce push notifications types with API less than v64.0")
return null
}
Expand Down Expand Up @@ -98,7 +98,7 @@ class NotificationsApiClient(
val apiVersion = ApiVersionStrings.getVersionNumber(context)

// Submit the request.
if (apiVersion < "v64.0") { // TODO: Remove once MSDK default API version is 64 or greater.
if (apiVersion < "v64.0") {
SalesforceSDKLogger.w(TAG, "Cannot submit Salesforce Notifications API action with API less than v64.0")
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ class PushMessagingTest {
notificationsTypes = fromJson(NOTIFICATIONS_TYPES_JSON)
)

ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

// Test once for coverage only with the default REST client.
assertThrows(SSLPeerUnverifiedException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
Expand All @@ -231,24 +229,12 @@ class PushMessagingTest {
fun testInvokeServerNotificationActionViaSdkManager_WithoutAccount() {
val salesforceSdkManager = SalesforceSDKManager.getInstance()

val restResponse = mockk<RestResponse>()
every { restResponse.asString() } returns encodeToString(
NotificationsActionsResponseBody.serializer(),
NotificationsActionsResponseBody(
message = "test_message"
assertThrows(NullPointerException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
actionKey = "test_action_key",
)
)
every { restResponse.isSuccess } returns true
val restClient = mockk<RestClient>()
every { restClient.sendSync(any()) } returns restResponse

val notificationsActionsResponseBody = salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
actionKey = "test_action_key",
restClient = restClient
)

assertNull(notificationsActionsResponseBody)
}
}

@Test
Expand All @@ -273,6 +259,8 @@ class PushMessagingTest {
notificationsTypes = fromJson(NOTIFICATIONS_TYPES_JSON)
)

ApiVersionStrings.VERSION_NUMBER_TEST = "v63.0"

val notificationsActionsResponseBody = salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
actionKey = "test_action_key",
Expand All @@ -299,8 +287,6 @@ class PushMessagingTest {
notificationsTypes = fromJson(NOTIFICATIONS_TYPES_JSON)
)

ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

assertThrows(NotificationsApiException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
Expand Down Expand Up @@ -330,8 +316,6 @@ class PushMessagingTest {
notificationsTypes = fromJson(NOTIFICATIONS_TYPES_JSON)
)

ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

assertThrows(NotificationsApiException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
Expand Down Expand Up @@ -368,9 +352,6 @@ class PushMessagingTest {
every { restClient.clientInfo } returns clientInfo
every { restClient.sendSync(any()) } returns restResponse

// Setup.
ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

assertThrows(NotificationsApiException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
Expand All @@ -396,9 +377,6 @@ class PushMessagingTest {
every { restClient.clientInfo } returns clientInfo
every { restClient.sendSync(any()) } returns restResponse

// Setup.
ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

assertThrows(NotificationsApiException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
Expand Down Expand Up @@ -431,9 +409,6 @@ class PushMessagingTest {
every { restClient.clientInfo } returns clientInfo
every { restClient.sendSync(any()) } returns restResponse

// Setup.
ApiVersionStrings.VERSION_NUMBER_TEST = "v64.0"

assertThrows(NotificationsApiException::class.java) {
salesforceSdkManager.invokeServerNotificationAction(
notificationId = "test_notification_id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class PushServiceTest {
val restClient = mockk<RestClient>()
every { restClient.sendSync(any()) } returns restResponse

// Setup.
VERSION_NUMBER_TEST = "v63.0"

val notificationsTypesResponseBody = PushService().fetchNotificationsTypes(
restClient = restClient,
userAccount = createTestAccount()
Expand Down Expand Up @@ -285,6 +288,7 @@ class PushServiceTest {
every { restResponse.asString() } returns NOTIFICATIONS_TYPES_JSON
every { restResponse.isSuccess } returns true
val restClient = mockk<RestClient>()
every { restClient.clientInfo } returns clientInfo
every { restClient.sendSync(any()) } returns restResponse

var result = false
Expand Down Expand Up @@ -746,6 +750,7 @@ class PushServiceTest {
every { restResponse.statusCode } returns HTTP_CREATED
every { restResponse.asJSONObject() } returns JSONObject("{\"id\": \"test_id\"}")
val restClient = mockk<RestClient>()
every { restClient.clientInfo } returns clientInfo
every { restClient.sendSync(any()) } returns restResponse

val account = createTestAccount()
Expand All @@ -765,9 +770,14 @@ class PushServiceTest {
restClient = restClient
)

verify(exactly = 1) {
verify(atLeast = 1) {
restClient.sendSync(withArg {
assertEquals("test_community_id", it.requestBodyAsJson.get("NetworkId"))
assertEquals(
"test_community_id",
runCatching {
it.requestBodyAsJson.get("NetworkId")
}.getOrDefault("Default Value")
)
})
}

Expand Down