Skip to content

Commit

Permalink
style: move helper method below test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
wzieba committed Oct 25, 2023
1 parent df99e84 commit 4c8c002
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,6 @@ internal class EngagementManagerTest {
)
}

private fun MapAssert<String, Any>.isCorrectEvent(
withTotalTime: AbstractLongAssert<*>.() -> AbstractLongAssert<*>,
withTimestamp: AbstractLongAssert<*>.() -> AbstractLongAssert<*>,
): MapAssert<String, Any> {
return containsEntry("action", "heartbeat")
// Incremental will be always 0 because the interval is lower than 1s
.containsEntry("inc", 0L)
.hasEntrySatisfying("tt") { totalTime ->
totalTime as Long
assertThat(totalTime).withTotalTime()
}
.hasEntrySatisfying("data") { data ->
data as Map<String, Any>
assertThat(data).hasEntrySatisfying("ts") { timestamp ->
timestamp as Long
assertThat(timestamp).withTimestamp()
}.containsAllEntriesOf(testData)
}
}

@Test
fun `when starting manager, then schedule task each interval period`() {
sut.start()
Expand Down Expand Up @@ -120,6 +100,26 @@ internal class EngagementManagerTest {
)
}

private fun MapAssert<String, Any>.isCorrectEvent(
withTotalTime: AbstractLongAssert<*>.() -> AbstractLongAssert<*>,
withTimestamp: AbstractLongAssert<*>.() -> AbstractLongAssert<*>,
): MapAssert<String, Any> {
return containsEntry("action", "heartbeat")
// Incremental will be always 0 because the interval is lower than 1s
.containsEntry("inc", 0L)
.hasEntrySatisfying("tt") { totalTime ->
totalTime as Long
assertThat(totalTime).withTotalTime()
}
.hasEntrySatisfying("data") { data ->
data as Map<String, Any>
assertThat(data).hasEntrySatisfying("ts") { timestamp ->
timestamp as Long
assertThat(timestamp).withTimestamp()
}.containsAllEntriesOf(testData)
}
}

class FakeTracker : ParselyTracker(
"",
0,
Expand Down

0 comments on commit 4c8c002

Please sign in to comment.