Skip to content

Commit

Permalink
Fix outcomes unit tests so tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
emawby authored and jinliu9508 committed Jan 31, 2024
1 parent 895943f commit f6f48b1
Showing 1 changed file with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class OutcomeEventsControllerTests : FunSpec({
Logging.logLevel = LogLevel.NONE
}

fun createTestSubscriptionModel(): SubscriptionModel {
val subModel = SubscriptionModel()
subModel.id = "subscriptionId"
subModel.address = "subscriptionAddress"
subModel.optedIn = true
return subModel
}

test("send outcome with disabled influences") {
/* Given */
val now = 111L
Expand Down Expand Up @@ -86,8 +94,7 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.UNATTRIBUTED, null))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)
Expand Down Expand Up @@ -132,8 +139,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.INDIRECT, JSONArray(notificationIds)))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -178,8 +185,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.DIRECT, JSONArray(notificationIds)))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -224,8 +231,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.UNATTRIBUTED, null))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -268,8 +275,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.UNATTRIBUTED, null))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -322,8 +329,8 @@ class OutcomeEventsControllerTests : FunSpec({
coEvery { mockOutcomeEventsRepository.getNotCachedUniqueInfluencesForOutcome("OUTCOME_1", any()) } returns listOf(notificationInfluence) andThen listOf()
coEvery { mockOutcomeEventsRepository.saveUniqueOutcomeEventParams(any()) } answers { waiter.wake() }

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -376,8 +383,8 @@ class OutcomeEventsControllerTests : FunSpec({
val notificationInfluence2 = Influence(InfluenceChannel.NOTIFICATION, InfluenceType.DIRECT, JSONArray(notificationIds2))
every { mockInfluenceManager.influences } returns listOf(notificationInfluence1) andThen listOf(notificationInfluence2)

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -438,8 +445,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockInfluenceManager = mockk<IInfluenceManager>()
every { mockInfluenceManager.influences } returns listOf(Influence(InfluenceChannel.NOTIFICATION, InfluenceType.UNATTRIBUTED, null))

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -483,8 +490,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockSessionService = mockk<ISessionService>()
every { mockSessionService.subscribe(any()) } just Runs

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down Expand Up @@ -571,8 +578,8 @@ class OutcomeEventsControllerTests : FunSpec({
val mockSessionService = mockk<ISessionService>()
every { mockSessionService.subscribe(any()) } just Runs

val subscriptionModel = SubscriptionModel()
subscriptionModel.id = "subscriptionId"
val subscriptionModel = createTestSubscriptionModel()

val mockSubscriptionManager = mockk<ISubscriptionManager>()
every { mockSubscriptionManager.subscriptions.push } returns PushSubscription(subscriptionModel)

Expand Down

0 comments on commit f6f48b1

Please sign in to comment.