Renaming helpers to clarify purpose
This commit is contained in:
parent
e3981f42e9
commit
2c96179383
@ -164,8 +164,17 @@ internal class LiveLocationAggregationProcessorTest {
|
|||||||
)
|
)
|
||||||
fakeClock.givenEpoch(A_TIMESTAMP + 5000)
|
fakeClock.givenEpoch(A_TIMESTAMP + 5000)
|
||||||
fakeWorkManagerProvider.fakeWorkManager.expectEnqueueUniqueWork()
|
fakeWorkManagerProvider.fakeWorkManager.expectEnqueueUniqueWork()
|
||||||
val aggregatedEntity = mockLiveLocationShareAggregatedSummaryEntityForEvent()
|
val aggregatedEntity = givenLastSummaryQueryReturns(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)
|
||||||
val previousEntities = mockPreviousLiveLocationShareAggregatedSummaryEntities()
|
val previousEntities = givenActiveSummaryListQueryReturns(
|
||||||
|
listOf(
|
||||||
|
LiveLocationShareAggregatedSummaryEntity(
|
||||||
|
eventId = "${AN_EVENT_ID}1",
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
userId = A_SENDER_ID,
|
||||||
|
isActive = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val result = liveLocationAggregationProcessor.handleBeaconInfo(
|
val result = liveLocationAggregationProcessor.handleBeaconInfo(
|
||||||
realm = fakeRealm.instance,
|
realm = fakeRealm.instance,
|
||||||
@ -209,8 +218,18 @@ internal class LiveLocationAggregationProcessorTest {
|
|||||||
)
|
)
|
||||||
fakeClock.givenEpoch(A_TIMESTAMP + 5000)
|
fakeClock.givenEpoch(A_TIMESTAMP + 5000)
|
||||||
fakeWorkManagerProvider.fakeWorkManager.expectCancelUniqueWork()
|
fakeWorkManagerProvider.fakeWorkManager.expectCancelUniqueWork()
|
||||||
val aggregatedEntity = mockLiveLocationShareAggregatedSummaryEntityForEvent()
|
val aggregatedEntity = givenLastSummaryQueryReturns(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)
|
||||||
val previousEntities = mockPreviousLiveLocationShareAggregatedSummaryEntities()
|
val previousEntities = givenActiveSummaryListQueryReturns(
|
||||||
|
listOf(
|
||||||
|
LiveLocationShareAggregatedSummaryEntity(
|
||||||
|
eventId = "${AN_EVENT_ID}1",
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
userId = A_SENDER_ID,
|
||||||
|
isActive = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
val result = liveLocationAggregationProcessor.handleBeaconInfo(
|
val result = liveLocationAggregationProcessor.handleBeaconInfo(
|
||||||
realm = fakeRealm.instance,
|
realm = fakeRealm.instance,
|
||||||
@ -314,7 +333,11 @@ internal class LiveLocationAggregationProcessorTest {
|
|||||||
val lastBeaconLocationContent = MessageBeaconLocationDataContent(
|
val lastBeaconLocationContent = MessageBeaconLocationDataContent(
|
||||||
unstableTimestampMillis = A_TIMESTAMP
|
unstableTimestampMillis = A_TIMESTAMP
|
||||||
)
|
)
|
||||||
mockLiveLocationShareAggregatedSummaryEntityForEvent(lastBeaconLocationContent = lastBeaconLocationContent)
|
givenLastSummaryQueryReturns(
|
||||||
|
eventId = AN_EVENT_ID,
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
beaconLocationContent = lastBeaconLocationContent
|
||||||
|
)
|
||||||
|
|
||||||
val result = liveLocationAggregationProcessor.handleBeaconLocationData(
|
val result = liveLocationAggregationProcessor.handleBeaconLocationData(
|
||||||
realm = fakeRealm.instance,
|
realm = fakeRealm.instance,
|
||||||
@ -339,7 +362,11 @@ internal class LiveLocationAggregationProcessorTest {
|
|||||||
val lastBeaconLocationContent = MessageBeaconLocationDataContent(
|
val lastBeaconLocationContent = MessageBeaconLocationDataContent(
|
||||||
unstableTimestampMillis = A_TIMESTAMP - 60_000
|
unstableTimestampMillis = A_TIMESTAMP - 60_000
|
||||||
)
|
)
|
||||||
val entity = mockLiveLocationShareAggregatedSummaryEntityForEvent(lastBeaconLocationContent = lastBeaconLocationContent)
|
val entity = givenLastSummaryQueryReturns(
|
||||||
|
eventId = AN_EVENT_ID,
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
beaconLocationContent = lastBeaconLocationContent
|
||||||
|
)
|
||||||
|
|
||||||
val result = liveLocationAggregationProcessor.handleBeaconLocationData(
|
val result = liveLocationAggregationProcessor.handleBeaconLocationData(
|
||||||
realm = fakeRealm.instance,
|
realm = fakeRealm.instance,
|
||||||
@ -356,36 +383,32 @@ internal class LiveLocationAggregationProcessorTest {
|
|||||||
savedLocationData?.getBestLocationInfo()?.geoUri shouldBeEqualTo A_GEO_URI
|
savedLocationData?.getBestLocationInfo()?.geoUri shouldBeEqualTo A_GEO_URI
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mockLiveLocationShareAggregatedSummaryEntityForEvent(
|
private fun givenLastSummaryQueryReturns(
|
||||||
lastBeaconLocationContent: MessageBeaconLocationDataContent? = null
|
eventId: String,
|
||||||
|
roomId: String,
|
||||||
|
beaconLocationContent: MessageBeaconLocationDataContent? = null
|
||||||
): LiveLocationShareAggregatedSummaryEntity {
|
): LiveLocationShareAggregatedSummaryEntity {
|
||||||
val result = LiveLocationShareAggregatedSummaryEntity(
|
val result = LiveLocationShareAggregatedSummaryEntity(
|
||||||
eventId = AN_EVENT_ID,
|
eventId = eventId,
|
||||||
roomId = A_ROOM_ID,
|
roomId = roomId,
|
||||||
lastLocationContent = ContentMapper.map(lastBeaconLocationContent?.toContent())
|
lastLocationContent = ContentMapper.map(beaconLocationContent?.toContent())
|
||||||
)
|
)
|
||||||
fakeQuery
|
fakeQuery
|
||||||
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, AN_EVENT_ID)
|
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, eventId)
|
||||||
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, A_ROOM_ID)
|
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, roomId)
|
||||||
.givenFindFirst(result)
|
.givenFindFirst(result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mockPreviousLiveLocationShareAggregatedSummaryEntities(): List<LiveLocationShareAggregatedSummaryEntity> {
|
private fun givenActiveSummaryListQueryReturns(
|
||||||
val results = listOf(
|
summaryList: List<LiveLocationShareAggregatedSummaryEntity>
|
||||||
LiveLocationShareAggregatedSummaryEntity(
|
): List<LiveLocationShareAggregatedSummaryEntity> {
|
||||||
eventId = "",
|
|
||||||
roomId = A_ROOM_ID,
|
|
||||||
userId = A_SENDER_ID,
|
|
||||||
isActive = true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
fakeQuery
|
fakeQuery
|
||||||
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, A_ROOM_ID)
|
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, A_ROOM_ID)
|
||||||
.givenNotEqualTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, AN_EVENT_ID)
|
.givenNotEqualTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, AN_EVENT_ID)
|
||||||
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.USER_ID, A_SENDER_ID)
|
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.USER_ID, A_SENDER_ID)
|
||||||
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, true)
|
.givenEqualTo(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, true)
|
||||||
.givenFindAll(results)
|
.givenFindAll(summaryList)
|
||||||
return results
|
return summaryList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user