Skip to content

Commit aeb4553

Browse files
committed
update tests
No actual logic changes to tests
1 parent dcef4a9 commit aeb4553

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/user/internal/operations/LoginUserOperationExecutorTests.kt

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.onesignal.user.internal.operations
22

33
import br.com.colman.kotest.android.extensions.robolectric.RobolectricTest
4+
import com.onesignal.common.consistency.RywData
5+
import com.onesignal.common.consistency.models.IConsistencyManager
46
import com.onesignal.common.exceptions.BackendException
57
import com.onesignal.core.internal.operations.ExecutionResponse
68
import com.onesignal.core.internal.operations.ExecutionResult
@@ -25,10 +27,13 @@ import io.kotest.core.spec.style.FunSpec
2527
import io.kotest.matchers.collections.shouldBeOneOf
2628
import io.kotest.matchers.shouldBe
2729
import io.kotest.matchers.types.shouldBeInstanceOf
30+
import io.mockk.clearMocks
2831
import io.mockk.coEvery
2932
import io.mockk.coVerify
3033
import io.mockk.every
34+
import io.mockk.just
3135
import io.mockk.mockk
36+
import io.mockk.runs
3237

3338
@RobolectricTest
3439
class LoginUserOperationExecutorTests : FunSpec({
@@ -39,6 +44,8 @@ class LoginUserOperationExecutorTests : FunSpec({
3944
val localSubscriptionId2 = "local-subscriptionId2"
4045
val remoteSubscriptionId1 = "remote-subscriptionId1"
4146
val remoteSubscriptionId2 = "remote-subscriptionId2"
47+
val rywData = RywData("1", 500L)
48+
val mockConsistencyManager = mockk<IConsistencyManager>()
4249
val createSubscriptionOperation =
4350
CreateSubscriptionOperation(
4451
appId,
@@ -50,6 +57,11 @@ class LoginUserOperationExecutorTests : FunSpec({
5057
SubscriptionStatus.SUBSCRIBED,
5158
)
5259

60+
beforeTest {
61+
clearMocks(mockConsistencyManager)
62+
coEvery { mockConsistencyManager.setRywData(any(), any(), any()) } just runs
63+
}
64+
5365
test("login anonymous user successfully creates user") {
5466
// Given
5567
val mockUserBackendService = mockk<IUserBackendService>()
@@ -58,6 +70,7 @@ class LoginUserOperationExecutorTests : FunSpec({
5870
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
5971
PropertiesObject(),
6072
listOf(),
73+
rywData,
6174
)
6275
// Given
6376
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
@@ -76,6 +89,7 @@ class LoginUserOperationExecutorTests : FunSpec({
7689
mockSubscriptionsModelStore,
7790
MockHelper.configModelStore(),
7891
MockHelper.languageContext(),
92+
mockConsistencyManager,
7993
)
8094
val operations =
8195
listOf<Operation>(
@@ -120,6 +134,7 @@ class LoginUserOperationExecutorTests : FunSpec({
120134
mockSubscriptionsModelStore,
121135
MockHelper.configModelStore(),
122136
MockHelper.languageContext(),
137+
mockConsistencyManager,
123138
)
124139
val operations =
125140
listOf<Operation>(
@@ -148,7 +163,7 @@ class LoginUserOperationExecutorTests : FunSpec({
148163
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
149164

150165
val loginUserOperationExecutor =
151-
LoginUserOperationExecutor(mockIdentityOperationExecutor, AndroidMockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
166+
LoginUserOperationExecutor(mockIdentityOperationExecutor, AndroidMockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
152167
val operations =
153168
listOf<Operation>(
154169
LoginUserOperation(appId, localOneSignalId, null, null),
@@ -167,7 +182,7 @@ class LoginUserOperationExecutorTests : FunSpec({
167182
// Given
168183
val mockUserBackendService = mockk<IUserBackendService>()
169184
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } returns
170-
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf())
185+
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf(), rywData)
171186

172187
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
173188

@@ -176,7 +191,7 @@ class LoginUserOperationExecutorTests : FunSpec({
176191
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
177192

178193
val loginUserOperationExecutor =
179-
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
194+
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
180195
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", null))
181196

182197
// When
@@ -195,7 +210,7 @@ class LoginUserOperationExecutorTests : FunSpec({
195210
// Given
196211
val mockUserBackendService = mockk<IUserBackendService>()
197212
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } returns
198-
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf())
213+
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf(), rywData)
199214

200215
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
201216

@@ -214,6 +229,7 @@ class LoginUserOperationExecutorTests : FunSpec({
214229
mockSubscriptionsModelStore,
215230
MockHelper.configModelStore(),
216231
MockHelper.languageContext(),
232+
mockConsistencyManager,
217233
)
218234
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", null))
219235

@@ -242,7 +258,7 @@ class LoginUserOperationExecutorTests : FunSpec({
242258
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
243259

244260
val loginUserOperationExecutor =
245-
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
261+
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
246262
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", "existingOneSignalId"))
247263

248264
// When
@@ -268,7 +284,7 @@ class LoginUserOperationExecutorTests : FunSpec({
268284
// Given
269285
val mockUserBackendService = mockk<IUserBackendService>()
270286
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } returns
271-
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf())
287+
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf(), rywData)
272288

273289
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
274290
coEvery { mockIdentityOperationExecutor.execute(any()) } returns ExecutionResponse(ExecutionResult.FAIL_RETRY)
@@ -278,7 +294,7 @@ class LoginUserOperationExecutorTests : FunSpec({
278294
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
279295

280296
val loginUserOperationExecutor =
281-
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
297+
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
282298
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", "existingOneSignalId"))
283299

284300
// When
@@ -304,7 +320,7 @@ class LoginUserOperationExecutorTests : FunSpec({
304320
// Given
305321
val mockUserBackendService = mockk<IUserBackendService>()
306322
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } returns
307-
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf())
323+
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf(), rywData)
308324

309325
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
310326
coEvery { mockIdentityOperationExecutor.execute(any()) } returns ExecutionResponse(ExecutionResult.FAIL_NORETRY)
@@ -314,7 +330,7 @@ class LoginUserOperationExecutorTests : FunSpec({
314330
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
315331

316332
val loginUserOperationExecutor =
317-
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
333+
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
318334
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", "existingOneSignalId"))
319335

320336
// When
@@ -352,7 +368,7 @@ class LoginUserOperationExecutorTests : FunSpec({
352368
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
353369

354370
val loginUserOperationExecutor =
355-
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
371+
LoginUserOperationExecutor(mockIdentityOperationExecutor, MockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext(), mockConsistencyManager)
356372
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, "externalId", "existingOneSignalId"))
357373

358374
// When
@@ -385,6 +401,7 @@ class LoginUserOperationExecutorTests : FunSpec({
385401
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
386402
PropertiesObject(),
387403
listOf(),
404+
rywData,
388405
)
389406
// Given
390407
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
@@ -403,6 +420,7 @@ class LoginUserOperationExecutorTests : FunSpec({
403420
mockSubscriptionsModelStore,
404421
MockHelper.configModelStore(),
405422
MockHelper.languageContext(),
423+
mockConsistencyManager,
406424
)
407425
val operations =
408426
listOf<Operation>(
@@ -471,6 +489,7 @@ class LoginUserOperationExecutorTests : FunSpec({
471489
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
472490
PropertiesObject(),
473491
listOf(SubscriptionObject(remoteSubscriptionId1, SubscriptionObjectType.ANDROID_PUSH), SubscriptionObject(remoteSubscriptionId2, SubscriptionObjectType.EMAIL)),
492+
rywData,
474493
)
475494
// Given
476495
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
@@ -504,6 +523,7 @@ class LoginUserOperationExecutorTests : FunSpec({
504523
mockSubscriptionsModelStore,
505524
MockHelper.configModelStore(),
506525
MockHelper.languageContext(),
526+
mockConsistencyManager,
507527
)
508528
val operations =
509529
listOf<Operation>(
@@ -557,6 +577,7 @@ class LoginUserOperationExecutorTests : FunSpec({
557577
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
558578
PropertiesObject(),
559579
listOf(SubscriptionObject(remoteSubscriptionId1, SubscriptionObjectType.ANDROID_PUSH), SubscriptionObject(remoteSubscriptionId2, SubscriptionObjectType.EMAIL)),
580+
rywData,
560581
)
561582
// Given
562583
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
@@ -590,6 +611,7 @@ class LoginUserOperationExecutorTests : FunSpec({
590611
mockSubscriptionsModelStore,
591612
MockHelper.configModelStore(),
592613
MockHelper.languageContext(),
614+
mockConsistencyManager,
593615
)
594616
val operations =
595617
listOf<Operation>(
@@ -643,6 +665,7 @@ class LoginUserOperationExecutorTests : FunSpec({
643665
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
644666
PropertiesObject(),
645667
listOf(SubscriptionObject(remoteSubscriptionId1, SubscriptionObjectType.ANDROID_PUSH), SubscriptionObject(remoteSubscriptionId2, SubscriptionObjectType.EMAIL)),
668+
rywData,
646669
)
647670
// Given
648671
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
@@ -662,6 +685,7 @@ class LoginUserOperationExecutorTests : FunSpec({
662685
mockSubscriptionsModelStore,
663686
MockHelper.configModelStore(),
664687
MockHelper.languageContext(),
688+
mockConsistencyManager,
665689
)
666690
val operations =
667691
listOf<Operation>(
@@ -706,7 +730,7 @@ class LoginUserOperationExecutorTests : FunSpec({
706730
// Given
707731
val mockUserBackendService = mockk<IUserBackendService>()
708732
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } returns
709-
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf())
733+
CreateUserResponse(mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId), PropertiesObject(), listOf(), rywData)
710734

711735
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
712736

@@ -725,6 +749,7 @@ class LoginUserOperationExecutorTests : FunSpec({
725749
mockSubscriptionsModelStore,
726750
MockHelper.configModelStore(),
727751
MockHelper.languageContext(),
752+
mockConsistencyManager,
728753
)
729754
// anonymous Login request
730755
val operations = listOf<Operation>(LoginUserOperation(appId, localOneSignalId, null, null))

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/user/internal/operations/RefreshUserOperationExecutorTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class RefreshUserOperationExecutorTests : FunSpec({
4949
SubscriptionObject(remoteSubscriptionId1, SubscriptionObjectType.ANDROID_PUSH, enabled = true, token = "pushToken2"),
5050
SubscriptionObject(remoteSubscriptionId2, SubscriptionObjectType.EMAIL, token = "[email protected]"),
5151
),
52+
null,
5253
)
5354

5455
// Given
@@ -142,6 +143,7 @@ class RefreshUserOperationExecutorTests : FunSpec({
142143
mapOf(IdentityConstants.ONESIGNAL_ID to remoteOneSignalId),
143144
PropertiesObject(),
144145
listOf(),
146+
null,
145147
)
146148

147149
// Given

0 commit comments

Comments
 (0)